AvMediaPlayer class
The class to create and control AvMediaPlayer instance.
Do NOT modify properties directly, use the corresponding methods instead.
Constructors
- AvMediaPlayer({String? initSource, double? initVolume, double? initSpeed, bool? initLooping, bool? initAutoPlay, int? initPosition, bool? initShowSubtitle, String? initPreferredSubtitleLanguage, String? initPreferredAudioLanguage, int? initMaxBitRate, Size? initMaxResolution})
- All the parameters are optional, and can be changed later by calling the corresponding methods.
Properties
-
autoPlay
→ ValueNotifier<
bool> -
Whether the player should play the media automatically.
It's false by default.
final
-
bufferRange
→ ValueNotifier<
BufferRange> -
The current buffer status of the player.
It is only reported by network media.
final
- disposed ↔ bool
-
Whether the player is disposed.
getter/setter pair
-
error
→ ValueNotifier<
String?> -
The error message of the player.
It's null before an error occurs.
final
-
finishedTimes
→ ValueNotifier<
int> -
How many times the player has finished playing the current media.
It will be reset to 0 when the media is closed.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
→ ValueNotifier<
int?> -
The id of the player. It's null before the player is initialized.
After the player is initialized it will be unique and never change again.
final
-
loading
→ ValueNotifier<
bool> -
The loading state of the player.
It's false before opening a media.
final
-
looping
→ ValueNotifier<
bool> -
Whether the player should loop the media.
It's false by default.
final
-
maxBitRate
→ ValueNotifier<
int> -
Current maximum bit rate of the player. 0 means no limit.
final
-
maxResolution
→ ValueNotifier<
Size> -
Current maximum resolution of the player. Size.zero means no limit.
final
-
mediaInfo
→ ValueNotifier<
MediaInfo?> -
The information of the current media.
It's null before the media is opened.
final
-
overrideTracks
→ ValueNotifier<
Set< String> > -
The tracks that are overrided by the player.
final
-
playbackState
→ ValueNotifier<
PlaybackState> -
The playback state of the player.
It's PlaybackState.closed berore a media is opened.
final
-
position
→ ValueNotifier<
int> -
The position of the current media in milliseconds.
It's 0 before the media is opened.
final
-
preferredAudioLanguage
→ ValueNotifier<
String> -
The preferred audio language of the player.
final
-
preferredSubtitleLanguage
→ ValueNotifier<
String> -
The preferred subtitle language of the player.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
showSubtitle
→ ValueNotifier<
bool> -
Whether to show subtitles.
By default, the player does not show any subtitles. Regardless of the preferred subtitle language or override tracks.
final
-
speed
→ ValueNotifier<
double> -
The speed of the player.
It's between 0.5 and 2, and defaults to 1.
final
- subId ↔ int?
-
The id of the subtitle texture if available.
This value does not change after the player is initialized.
getter/setter pair
-
videoSize
→ ValueNotifier<
Size> -
The size of the current video.
This value is Size.zero by default, and may change during playback.
final
-
volume
→ ValueNotifier<
double> -
The volume of the player.
It's between 0 and 1, and defaults to 1.
final
Methods
-
close(
) → void - Close or stop opening the media file.
-
dispose(
) → void - Dispose the player
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
open(
String source) → void - Open a media file
-
overrideTrack(
String trackId, bool enabled) → bool -
Force the player to override a track. Or cancel the override.
The
trackId
is a key of MediaInfo.tracks. -
pause(
) → bool - Pause the current media file.
-
play(
) → bool - Play the current media file.
-
seekTo(
int position) → bool - Seek to a specific position.
-
setAutoPlay(
bool autoPlay) → bool - Set whether the player should play the media automatically.
-
setLooping(
bool looping) → bool - Set whether the player should loop the media.
-
setMaxBitRate(
int bitrate) → bool - Set the maximum bit rate of the player. This method may not work on windows.
-
setMaxResolution(
Size resolution) → bool - Set the maximum resolution of the player. This method may not work on windows.
-
setPreferredAudioLanguage(
String language) → bool - Set the preferred audio language of the player. An empty string means using the system default.
-
setPreferredSubtitleLanguage(
String language) → bool - Set the preferred subtitle language of the player. An empty string means using the system default.
-
setShowSubtitle(
bool show) → bool - Set whether to show subtitles.
-
setSpeed(
double speed) → bool - Set playback speed of the player.
-
setVolume(
double volume) → bool - Set the volume of the player.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited