VlcPlayerController class

Controls a platform vlc player, and provides updates when the state is changing.

Instances must be initialized with initialize.

The video is displayed in a Flutter app by creating a VlcPlayer widget.

To reclaim the resources used by the player call dispose.

After dispose all further calls are ignored.

Inheritance

Constructors

VlcPlayerController.asset(String dataSource, {bool autoInitialize = true, bool allowBackgroundPlayback = false, String? package, HwAcc hwAcc = HwAcc.auto, bool autoPlay = true, VlcPlayerOptions? options, @Deprecated('Please, use the addOnInitListener method instead.') VoidCallback? onInit, @Deprecated('Please, use the addOnRendererEventListener method instead.') RendererCallback? onRendererHandler})
The name of the asset is given by the dataSource argument and must not be null. The package argument must be non-null when the asset comes from a package and null otherwise.
VlcPlayerController.file(File file, {bool autoInitialize = true, bool allowBackgroundPlayback = true, HwAcc hwAcc = HwAcc.auto, bool autoPlay = true, VlcPlayerOptions? options, @Deprecated('Please, use the addOnInitListener method instead.') VoidCallback? onInit, @Deprecated('Please, use the addOnRendererEventListener method instead.') RendererCallback? onRendererHandler})
Constructs a VlcPlayerController playing a video from a file.
VlcPlayerController.network(String dataSource, {bool autoInitialize = true, bool allowBackgroundPlayback = false, HwAcc hwAcc = HwAcc.auto, bool autoPlay = true, VlcPlayerOptions? options, @Deprecated('Please, use the addOnInitListener method instead.') VoidCallback? onInit, @Deprecated('Please, use the addOnRendererEventListener method instead.') RendererCallback? onRendererHandler})
Constructs a VlcPlayerController playing a video from obtained from the network.

Properties

allowBackgroundPlayback bool
Set keep playing video in background, when app goes in background. The default value is false.
final
autoInitialize bool
Initialize vlc player when the platform is ready automatically
final
autoPlay bool
The video should be played automatically.
final
dataSource String
The URI to the video file. This will be in different formats depending on the DataSourceType of the original video.
final
dataSourceType DataSourceType
Describes the type of data source this VlcPlayerController is constructed with.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
hwAcc HwAcc
Set hardware acceleration for player. Default is Automatic.
final
isReadyToInitialize bool?
Determine if platform is ready to call initialize method
no setter
options VlcPlayerOptions?
Adds options to vlc. For more https://wiki.videolan.org/VLC_command-line_help If nothing is provided, vlc will run without any options set.
final
package String?
Only set for asset videos. The package that the asset was loaded from.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value VlcPlayerValue
The current value stored in this notifier.
getter/setter pairinherited
viewId int?
This is just exposed for testing. It shouldn't be used by anyone depending on the plugin.
no setter

Methods

addAudioFromFile(File file, {bool? isSelected}) Future<void>
Add extra audio file to media. file - Audio file isSelected - Set true if you wanna force the added audio to start playing on media.
addAudioFromNetwork(String dataSource, {bool? isSelected}) Future<void>
Add extra network audio to media. dataSource - Url of audio isSelected - Set true if you wanna force the added audio to start playing on media.
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
addOnInitListener(VoidCallback listener) → void
Register a VoidCallback closure to be called when the controller gets initialized
addOnRendererEventListener(RendererCallback listener) → void
Register a RendererCallback closure to be called when a cast renderer device gets attached/detached
addSubtitleFromFile(File file, {bool? isSelected}) Future<void>
Add extra subtitle file to media. file - Subtitle file isSelected - Set true if you wanna force the added subtitle to start display on media.
addSubtitleFromNetwork(String dataSource, {bool? isSelected}) Future<void>
Add extra network subtitle to media. dataSource - Url of subtitle isSelected - Set true if you wanna force the added subtitle to start display on media.
castToRenderer(String castDevice) Future<void>
castDevice - name of renderer device Start vlc video casting to the selected device. Set null if you wanna stop video casting.
dispose() Future<void>
Dispose controller
override
getAudioDelay() Future<int?>
Returns the amount of audio track time delay in millisecond.
getAudioTrack() Future<int?>
Returns active audio track index
getAudioTracks() Future<Map<int, String>>
Returns all audio tracks as array of <Int, String> The key parameter is the index of audio track which is used for changing audio and the value is the display name of audio
getAudioTracksCount() Future<int?>
Returns the number of audio tracks
getAvailableRendererServices() Future<List<String>>
Get list of available renderer services which is supported by vlc library
getDuration() Future<Duration>
Returns duration/length of loaded video
getPlaybackSpeed() Future<double?>
Returns the vlc playback speed.
getPosition() Future<Duration>
Returns the position in the current video.
getRendererDevices() Future<Map<String, String>>
Returns all detected renderer devices as array of <String, String> The key parameter is the name of cast device and the value is the display name of cast device
getSpuDelay() Future<int?>
Returns the amount of subtitle time delay.
getSpuTrack() Future<int?>
Returns active spu track index
getSpuTracks() Future<Map<int, String>>
Return all subtitle tracks as array of <Int, String> The key parameter is the index of subtitle which is used for changing subtitle and the value is the display name of subtitle
getSpuTracksCount() Future<int?>
Return the number of subtitle tracks (both embedded and inserted)
getTime() Future<int>
Get the video timestamp in millisecond
getVideoAspectRatio() Future<String?>
Returns video aspect ratio in string format
getVideoScale() Future<double?>
Returns video scale
getVideoTrack() Future<int?>
Returns active video track index
getVideoTracks() Future<Map<int, String>>
Returns all video tracks as array of <Int, String> The key parameter is the index of video track and the value is the display name of video track
getVideoTracksCount() Future<int?>
Returns the number of video tracks
getVolume() Future<int>
Returns current vlc volume level.
initialize() Future<void>
Attempts to open the given url and load metadata about the video.
isPlaying() Future<bool?>
Returns true if media is playing.
isSeekable() Future<bool?>
Returns true if media is seekable.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
onPlatformViewCreated(int viewId) Future<void>
viewId - the id of view that is generated by the platform This method will be called after the platform view has been created
pause() Future<void>
Pauses the video.
play() Future<void>
Starts playing the video.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
removeOnInitListener(VoidCallback listener) → void
Remove a previously registered closure from the list of onInit closures
removeOnRendererEventListener(RendererCallback listener) → void
Remove a previously registered closure from the list of OnRendererEvent closures
seekTo(Duration position) Future<void>
Sets the video's current timestamp to be at moment. The next time the video is played it will resume from the given moment.
setAudioDelay(int audioDelay) Future<void>
audioDelay - the amount of time in milliseconds which vlc audio should be delayed. (both positive & negative value appliable)
setAudioTrack(int audioTrackNumber) Future<void>
Change active audio track index (set -1 to mute). audioTrackNumber - the audio track index obtained from getAudioTracks()
setLooping(bool looping) Future<void>
Sets whether or not the video should loop after playing once.
setMediaFromAsset(String dataSource, {String? package, bool? autoPlay, HwAcc? hwAcc}) Future<void>
This stops playback and changes the data source. Once the new data source has been loaded, the playback state will revert to its state before the method was called. (i.e. if this method is called whilst media is playing, once the new data source has been loaded, the new stream will begin playing.) dataSource - the path of the asset file.
setMediaFromFile(File file, {bool? autoPlay, HwAcc? hwAcc}) Future<void>
This stops playback and changes the data source. Once the new data source has been loaded, the playback state will revert to its state before the method was called. (i.e. if this method is called whilst media is playing, once the new data source has been loaded, the new stream will begin playing.) file - the File stream to start playing.
setMediaFromNetwork(String dataSource, {bool? autoPlay, HwAcc? hwAcc}) Future<void>
This stops playback and changes the data source. Once the new data source has been loaded, the playback state will revert to its state before the method was called. (i.e. if this method is called whilst media is playing, once the new data source has been loaded, the new stream will begin playing.) dataSource - the URL of the stream to start playing.
setPlaybackSpeed(double speed) Future<void>
Sets the playback speed.
setSpuDelay(int spuDelay) Future<void>
spuDelay - the amount of time in milliseconds which vlc subtitle should be delayed. (both positive & negative value applicable)
setSpuTrack(int spuTrackNumber) Future<void>
Change active subtitle index (set -1 to disable subtitle). spuTrackNumber - the subtitle index obtained from getSpuTracks()
setTime(int time) Future<void>
Set video timestamp in millisecond
setVideoAspectRatio(String aspectRatio) Future<void>
aspectRatio - the video aspect ratio like "16:9"
setVideoScale(double videoScale) Future<void>
scale - the video scale value Set video scale
setVideoTrack(int videoTrackNumber) Future<void>
Change active video track index. videoTrackNumber - the video track index obtained from getVideoTracks()
setVolume(int volume) Future<void>
Sets the audio volume of
startRecording(String saveDirectory) Future<bool?>
saveDirectory - directory path of the recorded file Returns true if media is start recording.
startRendererScanning({String? rendererService}) Future<void>
Start vlc cast discovery to find external display devices (chromecast) By setting serviceName, the vlc discovers renderer with that service
stop() Future<void>
stops the video.
stopRecording() Future<bool?>
Returns true if media is stop recording.
stopRendererScanning() Future<void>
Stop vlc cast and scan
takeSnapshot() Future<Uint8List>
Returns binary data for a snapshot of the media at the current frame.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited