YoutubePlayerController class
Controls a youtube player, and provides updates when the state is changing.
The video is displayed in a Flutter app by creating a YoutubePlayerIFrame widget.
After YoutubePlayerController.close all further calls are ignored.
Constructors
- YoutubePlayerController({required String initialVideoId, YoutubePlayerParams params = const YoutubePlayerParams()})
- Creates YoutubePlayerController.
Properties
-
first
→ Future<
YoutubePlayerValue> -
The first element of this stream.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialVideoId → String
-
The Youtube video id for initial video to be loaded.
final
-
invokeJavascript
↔ Future<
void> Function(String function) -
Can be used to invokes javascript function.
getter/setter pair
- isBroadcast → bool
-
Whether this stream is a broadcast stream.
no setterinherited
-
isEmpty
→ Future<
bool> -
Whether this stream contains any elements.
no setterinherited
-
last
→ Future<
YoutubePlayerValue> -
The last element of this stream.
no setterinherited
-
length
→ Future<
int> -
The number of elements in this stream.
no setterinherited
- metadata → YoutubeMetaData
-
MetaData for the currently loaded or cued video.
no setter
- onEnterFullscreen ↔ VoidCallback?
-
Called when player enters fullscreen.
getter/setter pair
- onExitFullscreen ↔ VoidCallback?
-
Called when player exits fullscreen.
getter/setter pair
- params → YoutubePlayerParams
-
Defines default parameters for the player.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
single
→ Future<
YoutubePlayerValue> -
The single element of this stream.
no setterinherited
- value → YoutubePlayerValue
-
The
YoutubePlayerValue
.no setter
Methods
-
add(
YoutubePlayerValue data) → void -
Updates YoutubePlayerController with provided
data
.override -
any(
bool test(YoutubePlayerValue element)) → Future< bool> -
Checks whether
test
accepts any element provided by this stream.inherited -
asBroadcastStream(
{void onListen(StreamSubscription< YoutubePlayerValue> subscription)?, void onCancel(StreamSubscription<YoutubePlayerValue> subscription)?}) → Stream<YoutubePlayerValue> -
Returns a multi-subscription stream that produces the same events as this.
inherited
-
asyncExpand<
E> (Stream< E> ? convert(YoutubePlayerValue event)) → Stream<E> -
Transforms each element into a sequence of asynchronous events.
inherited
-
asyncMap<
E> (FutureOr< E> convert(YoutubePlayerValue event)) → Stream<E> -
Creates a new stream with each data event of this stream asynchronously
mapped to a new event.
inherited
-
cast<
R> () → Stream< R> -
Adapt this stream to be a
Stream<R>
.inherited -
close(
) → Future< void> -
Closes YoutubePlayerController.
override
-
contains(
Object? needle) → Future< bool> -
Returns whether
needle
occurs in the elements provided by this stream.inherited -
cue(
String videoId, {Duration startAt = Duration.zero, Duration? endAt}) → void - This function loads the specified video's thumbnail and prepares the player to play the video. The player does not request the FLV until YoutubePlayerController.play or YoutubePlayerController.seekTo is called.
-
cuePlaylist(
String list, {String listType = PlaylistType.playlist, int startAt = 0, int index = 0}) → void - Queues the specified list of videos. The list can be a playlist, a search results feed, or a user's uploaded videos feed. When the list is cued and ready to play, the player will broadcast a video cued event PlayerState.cued.
-
distinct(
[bool equals(YoutubePlayerValue previous, YoutubePlayerValue next)?]) → Stream< YoutubePlayerValue> -
Skips data events if they are equal to the previous data event.
inherited
-
drain<
E> ([E? futureValue]) → Future< E> -
Discards all data on this stream, but signals when it is done or an error
occurred.
inherited
-
elementAt(
int index) → Future< YoutubePlayerValue> -
Returns the value of the
index
th data event of this stream.inherited -
every(
bool test(YoutubePlayerValue element)) → Future< bool> -
Checks whether
test
accepts all elements provided by this stream.inherited -
expand<
S> (Iterable< S> convert(YoutubePlayerValue element)) → Stream<S> -
Transforms each element of this stream into a sequence of elements.
inherited
-
firstWhere(
bool test(YoutubePlayerValue element), {YoutubePlayerValue orElse()?}) → Future< YoutubePlayerValue> -
Finds the first element of this stream matching
test
.inherited -
fold<
S> (S initialValue, S combine(S previous, YoutubePlayerValue element)) → Future< S> -
Combines a sequence of values by repeatedly applying
combine
.inherited -
forEach(
void action(YoutubePlayerValue element)) → Future< void> -
Executes
action
on each element of this stream.inherited -
handleError(
Function onError, {bool test(dynamic error)?}) → Stream< YoutubePlayerValue> -
Creates a wrapper Stream that intercepts some errors from this stream.
inherited
-
hideEndScreen(
) → void - Hide EndScreen
-
hidePauseOverlay(
) → void - Hides pause overlay i.e. related videos shown when player is paused.
-
hideTopMenu(
) → void - Hides top menu i.e. title, playlist, share icon shown at top of the player.
-
hideYoutubeLogo(
) → void - Hide Youtube Logo
-
join(
[String separator = ""]) → Future< String> -
Combines the string representation of elements into a single string.
inherited
-
lastWhere(
bool test(YoutubePlayerValue element), {YoutubePlayerValue orElse()?}) → Future< YoutubePlayerValue> -
Finds the last element in this stream matching
test
.inherited -
listen(
void onData(YoutubePlayerValue event)?, {Function? onError, void onDone()?, bool? cancelOnError}) → StreamSubscription< YoutubePlayerValue> -
Listen to updates in YoutubePlayerController.
override
-
load(
String videoId, {Duration startAt = Duration.zero, Duration? endAt}) → void - This function loads and plays the specified video.
-
loadPlaylist(
String list, {String listType = PlaylistType.playlist, int startAt = 0, int index = 0}) → void - This function loads the specified list and plays it. The list can be a playlist, a search results feed, or a user's uploaded videos feed.
-
map<
S> (S convert(YoutubePlayerValue event)) → Stream< S> -
Transforms each element of this stream into a new stream event.
inherited
-
mute(
) → void - Mutes the player.
-
nextVideo(
) → void - This function loads and plays the next video in the playlist.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pause(
) → void - Pauses the currently playing video.
-
pipe(
StreamConsumer< YoutubePlayerValue> streamConsumer) → Future -
Pipes the events of this stream into
streamConsumer
.inherited -
play(
) → void - Plays the currently cued/loaded video.
-
playVideoAt(
int index) → void - This function loads and plays the specified video in the playlist.
-
previousVideo(
) → void - This function loads and plays the previous video in the playlist.
-
reduce(
YoutubePlayerValue combine(YoutubePlayerValue previous, YoutubePlayerValue element)) → Future< YoutubePlayerValue> -
Combines a sequence of values by repeatedly applying
combine
.inherited -
reset(
) → void - Resets the value of YoutubePlayerController.
-
seekTo(
Duration position, {bool allowSeekAhead = true}) → void - Seeks to a specified time in the video.
-
setLoop(
bool loop) → void - This function indicates whether the video player should continuously play a playlist or if it should stop playing after the last video in the playlist ends.
-
setPlaybackRate(
double rate) → void - Sets the playback speed for the video.
-
setShuffle(
bool shuffle) → void - This function indicates whether a playlist's videos should be shuffled so that they play back in an order different from the one that the playlist creator designated.
-
setSize(
Size size) → void - Sets the size in pixels of the player.
-
setVolume(
int volume) → void - Sets the volume of player. Max = 100 , Min = 0
-
showTopMenu(
) → void - Show top menu
-
singleWhere(
bool test(YoutubePlayerValue element), {YoutubePlayerValue orElse()?}) → Future< YoutubePlayerValue> -
Finds the single element in this stream matching
test
.inherited -
skip(
int count) → Stream< YoutubePlayerValue> -
Skips the first
count
data events from this stream.inherited -
skipWhile(
bool test(YoutubePlayerValue element)) → Stream< YoutubePlayerValue> -
Skip data events from this stream while they are matched by
test
.inherited -
stop(
) → void - Stops and cancels loading of the current video.
-
take(
int count) → Stream< YoutubePlayerValue> -
Provides at most the first
count
data events of this stream.inherited -
takeWhile(
bool test(YoutubePlayerValue element)) → Stream< YoutubePlayerValue> -
Forwards data events while
test
is successful.inherited -
timeout(
Duration timeLimit, {void onTimeout(EventSink< YoutubePlayerValue> sink)?}) → Stream<YoutubePlayerValue> -
Creates a new stream with the same events as this stream.
inherited
-
toList(
) → Future< List< YoutubePlayerValue> > -
Collects all elements of this stream in a
List
.inherited -
toSet(
) → Future< Set< YoutubePlayerValue> > -
Collects the data of this stream in a
Set
.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
transform<
S> (StreamTransformer< YoutubePlayerValue, S> streamTransformer) → Stream<S> -
Applies
streamTransformer
to this stream.inherited -
unMute(
) → void - Unmutes the player.
-
where(
bool test(YoutubePlayerValue event)) → Stream< YoutubePlayerValue> -
Creates a new stream from this stream that discards some elements.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
convertUrlToId(
String url, {bool trimWhitespaces = true}) → String? - Converts fully qualified YouTube Url to video id.
-
getThumbnail(
{required String videoId, String quality = ThumbnailQuality.standard, bool webp = true}) → String - Grabs YouTube video's thumbnail for provided video id.