YouTubeThumbnailLoader
com.google.android.youtube.player.YouTubeThumbnailLoader |
Overview
A YouTubeThumbnailLoader
provides methods for loading YouTube thumbnails into a
YouTubeThumbnailView
. Get an instance of this class by calling
initialize
on a YouTubeThumbnailView
.
Video and playlist IDs required by setVideo(String)
and setPlaylist(String)
methods are provided by the YouTube Data API. To learn more about this API, visit https://developers.google.com/youtube/v3/.
Note that you must call release()
when you are finished
with the YouTubeThumbnailLoader
.
Summary
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
YouTubeThumbnailLoader.ErrorReason | Describes the reasons for an error in a YouTubeThumbnailView . |
||||||||||
YouTubeThumbnailLoader.OnThumbnailLoadedListener | Interface definition for a listener that is invoked when a thumbnail has been loaded. |
Public methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Show the thumbnail of the first video in the playlist.
| |||||||||||
Determines whether the currently loaded playlist has a next video.
| |||||||||||
Determines whether the currently loaded playlist has a previous video.
| |||||||||||
Show the thumbnail of the next video in the playlist.
| |||||||||||
Show the thumbnail of the previous video in the playlist.
| |||||||||||
Releases system resources used by this
YouTubeThumbnailLoader . | |||||||||||
Set a
YouTubeThumbnailLoader.OnThumbnailLoadedListener which is invoked whenever a new
thumbnail has finished loading and has been displayed in this YouTube thumbnail view. | |||||||||||
Set this view to show thumbnail images for the given YouTube playlist ID, initially showing
the thumbnail for the video at the index specified in the
skipTo parameter. | |||||||||||
Set this view to show thumbnail images for the given YouTube playlist ID, initially showing
the thumbnail for the first video in the playlist.
| |||||||||||
Set this view to show the thumbnail image for the given YouTube video ID.
|
Public methods
public abstract void first ()
Show the thumbnail of the first video in the playlist.
public abstract boolean hasNext ()
Determines whether the currently loaded playlist has a next video.
Returns
true
if there is a next video in the playlist; otherwise returnsfalse
.
public abstract boolean hasPrevious ()
Determines whether the currently loaded playlist has a previous video.
Returns
true
if there is a previous video in the playlist; otherwise returnsfalse
.
public abstract void next ()
Show the thumbnail of the next video in the playlist.
Note that a second call to next()
or previous()
, before the first call
has finished (as indicated by
onThumbnailLoaded(YouTubeThumbnailView, String)
), might be
ignored.
Throws
NoSuchElementException | This exception is thrown if the method is called at the end of the playlist. |
public abstract void previous ()
Show the thumbnail of the previous video in the playlist.
Note that a second call to next()
or previous()
, before the first call
has finished (as indicated by
onThumbnailLoaded(YouTubeThumbnailView, String)
), might be
ignored.
Throws
NoSuchElementException | This exception is thrown if the method is called at the start of the playlist. |
public abstract void release ()
Releases system resources used by this YouTubeThumbnailLoader
.
Note that after calling this method any further interaction with this
YouTubeThumbnailLoader
is forbidden. A new instance must be created to load thumbnails
into a YouTubeThumbnailView
.
public abstract void setOnThumbnailLoadedListener (YouTubeThumbnailLoader.OnThumbnailLoadedListener listener)
Set a YouTubeThumbnailLoader.OnThumbnailLoadedListener
which is invoked whenever a new
thumbnail has finished loading and has been displayed in this YouTube thumbnail view.
Parameters
listener | The listener to register. |
public abstract void setPlaylist (String playlistId, int skipTo)
Set this view to show thumbnail images for the given YouTube playlist ID, initially showing
the thumbnail for the video at the index specified in the skipTo
parameter.
Parameters
playlistId | The ID for the playlist to show thumbnail images from, as returned from the YouTube Data API. |
skipTo | The video in the playlist to skip to. |
public abstract void setPlaylist (String playlistId)
Set this view to show thumbnail images for the given YouTube playlist ID, initially showing the thumbnail for the first video in the playlist.
Parameters
playlistId | The ID of the playlist to show thumbnail images from, as returned from the YouTube Data API. |
public abstract void setVideo (String videoId)
Set this view to show the thumbnail image for the given YouTube video ID.
Parameters
videoId | The ID of the video for which the thumbnail image is being shown, as returned from the YouTube Data API. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-11-04 UTC.