### get() Method Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-options.md Example demonstrating how to use the get() method to retrieve command-line arguments from VlcPlayerOptions. ```dart final options = VlcPlayerOptions( advanced: VlcAdvancedOptions([ VlcAdvancedOptions.networkCaching(2000), ]), video: VlcVideoOptions([ VlcVideoOptions.dropLateFrames(true), ]), ); final commandLineArgs = options.get(); // Result: ['--network-caching=2000', '--drop-late-frames'] ``` -------------------------------- ### startRendererScanning Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of starting a renderer scan for all services. ```dart await _controller.startRendererScanning(); ``` -------------------------------- ### Quick Start Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/README.md A basic Flutter application demonstrating how to use the flutter_vlc_player plugin to play a video from a network URL. ```dart import 'package:flutter/material.dart'; import 'package:flutter_vlc_player/flutter_vlc_player.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( visualDensity: VisualDensity.adaptivePlatformDensity, ), home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key}) : super(key: key); @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { VlcPlayerController _videoPlayerController; @override void initState() { super.initState(); _videoPlayerController = VlcPlayerController.network( 'https://media.w3.org/2010/05/sintel/trailer.mp4', hwAcc: HwAcc.full, autoPlay: false, options: VlcPlayerOptions(), ); } @override void dispose() async { super.dispose(); await _videoPlayerController.stopRendererScanning(); await _videoPlayerController.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: Center( child: VlcPlayer( controller: _videoPlayerController, aspectRatio: 16 / 9, placeholder: Center(child: CircularProgressIndicator()), ), ), ); } } ``` -------------------------------- ### File Constructor Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Example of creating a VlcPlayerController for a local file. ```dart import 'dart:io'; final file = File('/storage/emulated/0/Movies/video.mp4'); final controller = VlcPlayerController.file( file, autoPlay: false, ); ``` -------------------------------- ### Extra Options Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Example of passing raw VLC command-line arguments. ```dart final options = VlcPlayerOptions( extras: [ '--demux=h264', '--vvv', // Increase verbosity ], ); ``` -------------------------------- ### Recording Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the recording event to log when recording starts or stops and retrieve the file path. ```dart case VlcMediaEventType.recording: if (event.isRecording == true) { print('Recording started'); } else { print('Recording stopped: ${event.recordPath}'); } ``` -------------------------------- ### Complete Configuration Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md An example demonstrating how to configure the VlcPlayerController with various advanced options for network playback. ```dart import 'package:flutter_vlc_player/flutter_vlc_player.dart'; final controller = VlcPlayerController.network( 'https://example.com/video.mp4', autoInitialize: true, autoPlay: true, hwAcc: HwAcc.full, allowBackgroundPlayback: false, options: VlcPlayerOptions( advanced: VlcAdvancedOptions([ VlcAdvancedOptions.networkCaching(2000), ]), audio: VlcAudioOptions([ VlcAudioOptions.audioTimeStretch(true), ]), http: VlcHttpOptions([ VlcHttpOptions.httpReconnect(true), VlcHttpOptions.httpUserAgent('MyApp/1.0'), ]), video: VlcVideoOptions([ VlcVideoOptions.dropLateFrames(true), ]), subtitle: VlcSubtitleOptions([ VlcSubtitleOptions.fontSize(28), VlcSubtitleOptions.color(VlcSubtitleColor.white), VlcSubtitleOptions.boldStyle(true), ]), ), ); ``` -------------------------------- ### Play Video Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of starting video playback using the play() method. ```dart await _controller.play(); ``` -------------------------------- ### stopRecording Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of starting, performing playback, and then stopping a recording, and printing the recorded file path. ```dart // Start recording await _controller.startRecording('/sdcard/Movies'); // ... perform playback ... // Stop recording final result = await _controller.stopRecording(); if (result == true) { final recordedPath = _controller.value.recordPath; print('Recorded to: $recordedPath'); } ``` -------------------------------- ### Asset Constructor Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Examples of creating a VlcPlayerController for local assets and assets from another package. ```dart final controller = VlcPlayerController.asset( 'videos/sample.mp4', ); final controller = VlcPlayerController.asset( 'videos/sample.mp4', package: 'my_video_package', ); ``` -------------------------------- ### HwAcc Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/types.md Example of initializing VlcPlayerController with hardware acceleration. ```dart final controller = VlcPlayerController.network( url, hwAcc: HwAcc.full, ); ``` -------------------------------- ### Advanced Options Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Example of configuring file, network, and live caching, as well as clock synchronization. ```dart final options = VlcPlayerOptions( advanced: VlcAdvancedOptions([ VlcAdvancedOptions.fileCaching(300), VlcAdvancedOptions.networkCaching(2000), // Higher for slow connections VlcAdvancedOptions.liveCaching(500), ]), ); ``` -------------------------------- ### setVolume() Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of setting the volume to 50%. ```dart await _controller.setVolume(50); ``` -------------------------------- ### getRendererDevices Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of getting renderer devices and printing their display names and internal names. ```dart final devices = await _controller.getRendererDevices(); devices.forEach((name, displayName) { print('Device: $displayName ($name)'); }); ``` -------------------------------- ### Subtitle Options Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Example demonstrating how to configure subtitle appearance and styling using VlcSubtitleOptions. ```dart final options = VlcPlayerOptions( subtitle: VlcSubtitleOptions([ VlcSubtitleOptions.fontSize(28), VlcSubtitleOptions.color(VlcSubtitleColor.white), VlcSubtitleOptions.boldStyle(true), VlcSubtitleOptions.backgroundColor(VlcSubtitleColor.black), VlcSubtitleOptions.backgroundOpacity(200), VlcSubtitleOptions.outlineColor(VlcSubtitleColor.black), VlcSubtitleOptions.outlineThickness(VlcSubtitleThickness.normal), ]), ); ``` -------------------------------- ### getAvailableRendererServices Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of getting available renderer services and printing them. ```dart final services = await _controller.getAvailableRendererServices(); print('Available renderers: $services'); ``` -------------------------------- ### RTP/RTSP Options Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Example showing how to configure RTP over RTSP for better firewall compatibility. ```dart final options = VlcPlayerOptions( rtp: VlcRtpOptions([ VlcRtpOptions.rtpOverRtsp(true), // Force TCP for firewall compatibility ]), ); ``` -------------------------------- ### Network Constructor Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Examples of creating a VlcPlayerController for network streams, including progressive downloads and HLS/RTSP protocols. ```dart final controller = VlcPlayerController.network( 'https://example.com/video.mp4', ); final controller = VlcPlayerController.network( 'https://example.com/stream.m3u8', ); final controller = VlcPlayerController.network( 'rtsp://example.com:554/stream', ); ``` -------------------------------- ### VlcPlayer Widget Configuration Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Example of how to configure the VlcPlayer widget with essential parameters. ```dart VlcPlayer( controller: _controller, aspectRatio: 16 / 9, placeholder: Center( child: CircularProgressIndicator(), ), virtualDisplay: true, // Android setting ) ``` -------------------------------- ### getPosition() Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of how to get and print the current playback position. ```dart final position = await _controller.getPosition(); print('Current position: ${position.inSeconds}s'); ``` -------------------------------- ### HTTP Options Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Example of configuring HTTP options such as auto-reconnect, user-agent, and referrer. ```dart final options = VlcPlayerOptions( http: VlcHttpOptions([ VlcHttpOptions.httpReconnect(true), VlcHttpOptions.httpUserAgent('MyVideoApp/2.0'), VlcHttpOptions.httpReferrer('https://mysite.com'), ]), ); ``` -------------------------------- ### setSpuDelay() Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of how to set the subtitle delay/synchronization. ```dart await _controller.setSpuDelay(200); ``` -------------------------------- ### Audio Options Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Example of enabling audio time stretching to preserve pitch at different playback speeds. ```dart final options = VlcPlayerOptions( audio: VlcAudioOptions([ VlcAudioOptions.audioTimeStretch(true), // Preserve pitch at different speeds ]), ); ``` -------------------------------- ### VlcPlayer Widget Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-widget.md An example demonstrating how to use the VlcPlayer widget in a Flutter application, including controller setup and basic UI. ```dart import 'package:flutter/material.dart'; import 'package:flutter_vlc_player/flutter_vlc_player.dart'; class VideoScreen extends StatefulWidget { @override State createState() => _VideoScreenState(); } class _VideoScreenState extends State { late VlcPlayerController _controller; @override void initState() { super.initState(); _controller = VlcPlayerController.network( 'https://example.com/video.mp4', autoPlay: true, hwAcc: HwAcc.full, ); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( body: VlcPlayer( controller: _controller, aspectRatio: 16 / 9, placeholder: Center( child: CircularProgressIndicator(), ), ), ); } } ``` -------------------------------- ### VlcHttpOptions Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/types.md Example of configuring HTTP/network streaming options using VlcHttpOptions. ```dart final options = VlcPlayerOptions( http: VlcHttpOptions([ VlcHttpOptions.httpReconnect(true), VlcHttpOptions.httpUserAgent('MyApp/1.0'), ]), ); ``` -------------------------------- ### Stream Output Options Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Example for configuring stream output muxer caching. ```dart final options = VlcPlayerOptions( sout: VlcStreamOutputOptions([ VlcStreamOutputOptions.soutMuxCaching(1500), ]), ); ``` -------------------------------- ### Video Options Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Example of configuring video options like dropping late frames for smoother playback on slower devices. ```dart final options = VlcPlayerOptions( video: VlcVideoOptions([ VlcVideoOptions.dropLateFrames(true), ]), ); ``` -------------------------------- ### Example for uninitialized Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-value.md Example usage of the uninitialized factory constructor. ```dart final uninitialized = VlcPlayerValue.uninitialized(); ``` -------------------------------- ### VlcSubtitleThickness Usage Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/types.md Example of how to use VlcSubtitleThickness with VlcSubtitleOptions. ```dart VlcSubtitleOptions.outlineThickness(VlcSubtitleThickness.normal) ``` -------------------------------- ### VlcSubtitleOptions Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/types.md Example of configuring subtitle appearance and behavior using VlcSubtitleOptions. ```dart final options = VlcPlayerOptions( subtitle: VlcSubtitleOptions([ VlcSubtitleOptions.fontSize(24), VlcSubtitleOptions.color(VlcSubtitleColor.white), VlcSubtitleOptions.boldStyle(true), ]), ); ``` -------------------------------- ### setPlaybackSpeed() Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of setting playback speed to 1.5x. ```dart await _controller.setPlaybackSpeed(1.5); ``` -------------------------------- ### setVideoAspectRatio Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of setting the video aspect ratio to 16:9. ```dart await _controller.setVideoAspectRatio('16:9'); ``` -------------------------------- ### opening Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the 'opening' VlcMediaEvent, typically used to show a loading indicator. ```dart case VlcMediaEventType.opening: print('Media is opening...'); ``` -------------------------------- ### Error Handling Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of checking if the controller is initialized before calling methods, and initializing it if necessary. ```dart if (!_controller.value.isInitialized) { await _controller.initialize(); } ``` -------------------------------- ### Complete Event Listener Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md A complete example of adding a listener to the controller to handle various playback states and properties. ```dart controller.addListener(() { final value = controller.value; // Handle playback state from value if (value.hasError) { print('Error: ${value.errorDescription}'); } print('State: ${value.playingState}'); print('Position: ${value.position} / ${value.duration}'); }); ``` -------------------------------- ### getSpuTracks() Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of iterating through subtitle tracks and printing their indices and names. ```dart final tracks = await _controller.getSpuTracks(); tracks.forEach((index, name) { print('Subtitle $index: $name'); }); ``` -------------------------------- ### seekTo() Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of seeking to 30 seconds. ```dart await _controller.seekTo(Duration(seconds: 30)); ``` -------------------------------- ### VlcSubtitleColor Usage Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/types.md Example of how to use VlcSubtitleColor with VlcSubtitleOptions. ```dart VlcSubtitleOptions.color(VlcSubtitleColor.white) VlcSubtitleOptions.color(VlcSubtitleColor.rgb(red: 255, green: 255, blue: 255)) ``` -------------------------------- ### takeSnapshot Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of taking a snapshot and creating an Image object from the bytes. ```dart final imageBytes = await _controller.takeSnapshot(); if (imageBytes != null) { final image = Image.memory(imageBytes); } ``` -------------------------------- ### Track Management Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/README.md Examples of getting available audio, subtitle, and video tracks, and how to select or disable them. ```dart // Get available tracks final audioTracks = await controller.getAudioTracks(); final subtitles = await controller.getSpuTracks(); final videos = await controller.getVideoTracks(); // Select a track await controller.setAudioTrack(0); await controller.setSpuTrack(1); await controller.setVideoTrack(0); // Disable subtitles await controller.setSpuTrack(-1); // Mute audio await controller.setAudioTrack(-1); ``` -------------------------------- ### toString() Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-value.md Example output of the toString() method for VlcPlayerValue. ```dart print(controller.value); // Output: VlcPlayerValue(duration: 0:02:45.500000, size: Size(1920.0, 1080.0), position: 0:00:30.250000, playingState: PlayingState.playing, isInitialized: true, isPlaying: true, isLooping: false, isBuffering: false, isEnded: false, isRecording: false, bufferPercent: 100.0, volume: 80, playbackSpeed: 1.0, ...) ``` -------------------------------- ### setSpuTrack() Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of how to select an active subtitle track. ```dart await _controller.setSpuTrack(0); ``` -------------------------------- ### aspectRatio Getter Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-value.md Example of how to access the aspectRatio getter. ```dart final ratio = controller.value.aspectRatio; // 1.78 for 16:9 video ``` -------------------------------- ### start અRendererScanning Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Starts scanning for available cast devices. The optional `rendererService` parameter allows scanning for a specific service. ```dart Future startRendererScanning({String? rendererService}) ``` -------------------------------- ### Initialize VlcPlayerController Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of initializing a VlcPlayerController from a network source and awaiting its initialization. ```dart final controller = VlcPlayerController.network( 'https://example.com/video.mp4', autoInitialize: false, ); await controller.initialize(); ``` -------------------------------- ### Custom VLC Arguments Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-options.md Example showing how to pass custom raw VLC command-line arguments. ```dart final options = VlcPlayerOptions( extras: [ '--demux=h264', '--preferred-resolution=-1', ], ); ``` -------------------------------- ### Unknown Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the unknown event type for future compatibility. ```dart case VlcMediaEventType.unknown: print('Unknown event'); ``` -------------------------------- ### Buffering Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the buffering event to display buffer percentage and current position. ```dart case VlcMediaEventType.buffering: print('Buffer: ${event.bufferPercent}%'); print('Position: ${event.position}'); ``` -------------------------------- ### Usage Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-value.md Demonstrates how to access and listen to VlcPlayerValue changes. ```dart final controller = VlcPlayerController.network(url); // Access current state print('Duration: ${controller.value.duration}'); print('Position: ${controller.value.position}'); print('Is playing: ${controller.value.isPlaying}'); // Listen for state changes controller.addListener(() { final state = controller.value; print('State changed: $state'); }); // Use in a ValueListenableBuilder for reactive UI ValueListenableBuilder( valueListenable: controller, builder: (context, value, child) { return Text('Position: ${value.position.inSeconds}s / ${value.duration.inSeconds}s'); }, ) ``` -------------------------------- ### Unknown Renderer Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the unknown renderer event type for future compatibility. ```dart case VlcRendererEventType.unknown: print('Unknown renderer event'); ``` -------------------------------- ### Quick Start Source: https://github.com/solid-software/flutter_vlc_player/blob/master/flutter_vlc_player/README.md This code snippet demonstrates how to initialize and use the VlcPlayer widget for playing a network video. ```dart import 'package:flutter/material.dart'; import 'package:flutter_vlc_player/vlc_player_flutter.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( visualDensity: VisualDensity.adaptivePlatformDensity, ), home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key}) : super(key: key); @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { VlcPlayerController _videoPlayerController; Future initializePlayer() async {} @override void initState() { super.initState(); _videoPlayerController = VlcPlayerController.network( 'https://media.w3.org/2010/05/sintel/trailer.mp4', hwAcc: HwAcc.FULL, autoPlay: false, options: VlcPlayerOptions(), ); } @override void dispose() async { super.dispose(); await _videoPlayerController.stopRendererScanning(); await _videoViewController.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: Center( child: VlcPlayer( controller: _videoPlayerController, aspectRatio: 16 / 9, placeholder: Center(child: CircularProgressIndicator()), ), )); } } ``` -------------------------------- ### playing Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the 'playing' VlcMediaEvent, used to update UI with media information and initialize track selectors. ```dart case VlcMediaEventType.playing: print('Playing: ${event.duration}'); print('Video size: ${event.size}'); print('Audio tracks: ${event.audioTracksCount}'); ``` -------------------------------- ### Media Changed Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the mediaChanged event to log when the media source changes. ```dart case VlcMediaEventType.mediaChanged: print('Media source changed'); ``` -------------------------------- ### startRecording Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Starts recording the current video playback. The `saveDirectory` parameter specifies the path where the recorded file will be saved. Returns `true` if recording started, `false` if failed, `null` on error. ```dart Future startRecording(String saveDirectory) ``` -------------------------------- ### castToRenderer Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of casting video playback to a Chromecast device. ```dart await _controller.castToRenderer('chromecast-name'); ``` -------------------------------- ### Ended Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the ended event to log when playback finishes. ```dart case VlcMediaEventType.ended: print('Playback ended'); // Show next video button or auto-play next ``` -------------------------------- ### Renderer Attached Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the attached renderer event to log the found device name and add it to a list. ```dart case VlcRendererEventType.attached: print('Device found: ${event.rendererName}'); // Add to device list, enable casting button ``` -------------------------------- ### Basic Configuration Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-options.md Example of basic configuration using VlcPlayerOptions with network caching. ```dart final options = VlcPlayerOptions( advanced: VlcAdvancedOptions([ VlcAdvancedOptions.networkCaching(1500), ]), ); final controller = VlcPlayerController.network( 'https://example.com/video.mp4', options: options, ); ``` -------------------------------- ### Add OnInit Listener Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of adding a listener to be notified when the VlcPlayerController is initialized. ```dart _controller.addOnInitListener(() { print('Player initialized'); }); ``` -------------------------------- ### Subtitle Styling Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-options.md Example demonstrating various subtitle styling options. ```dart final options = VlcPlayerOptions( subtitle: VlcSubtitleOptions([ VlcSubtitleOptions.fontSize(32), VlcSubtitleOptions.boldStyle(true), VlcSubtitleOptions.color(VlcSubtitleColor.white), VlcSubtitleOptions.backgroundColor(VlcSubtitleColor.black), VlcSubtitleOptions.backgroundOpacity(180), VlcSubtitleOptions.outlineColor(VlcSubtitleColor.black), VlcSubtitleOptions.outlineThickness(VlcSubtitleThickness.normal), VlcSubtitleOptions.shadowColor(VlcSubtitleColor.black), VlcSubtitleOptions.shadowDistance(0.05), ]), ); ``` -------------------------------- ### Error Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the error event to log when a playback error occurs. ```dart case VlcMediaEventType.error: print('Playback error'); ``` -------------------------------- ### Time Changed Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the timeChanged event to calculate and print the playback progress. ```dart case VlcMediaEventType.timeChanged: final progress = event.position! / event.duration!; print('Progress: ${(progress * 100).toStringAsFixed(1)}%'); ``` -------------------------------- ### Live Stream Configuration Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-options.md Example for configuring options specific to live streaming scenarios. ```dart final options = VlcPlayerOptions( advanced: VlcAdvancedOptions([ VlcAdvancedOptions.liveCaching(500), VlcAdvancedOptions.clockSynchronization(1), // Enable clock sync ]), rtp: VlcRtpOptions([ VlcRtpOptions.rtpOverRtsp(true), // Force TCP for firewall ]), ); ``` -------------------------------- ### VlcPlayerController Recording Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Methods for starting and stopping video recording. ```dart Future startRecording(String saveDirectory) Future stopRecording() ``` -------------------------------- ### stopped Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the 'stopped' VlcMediaEvent, used to reset the playback UI state. ```dart case VlcMediaEventType.stopped: print('Playback stopped'); ``` -------------------------------- ### Initialize a Controller Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/README.md Examples of initializing a VlcPlayerController with different data source types: network stream, local file, and asset. ```dart final controller = VlcPlayerController.network( 'https://example.com/video.mp4', autoPlay: true, hwAcc: HwAcc.full, ); ``` ```dart import 'dart:io'; final controller = VlcPlayerController.file( File('/storage/emulated/0/Movies/video.mp4'), ); ``` ```dart final controller = VlcPlayerController.asset( 'assets/videos/sample.mp4', ); ``` -------------------------------- ### paused Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the 'paused' VlcMediaEvent, used to update the play/pause button UI. ```dart case VlcMediaEventType.paused: print('Playback paused'); ``` -------------------------------- ### Subtitle Selection UI Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/README.md Example of how to get available subtitle tracks and display a UI to select one. ```dart // Subtitle selection final subs = await controller.getSpuTracks(); showDialog( context: context, builder: (_) => SimpleDialog( title: Text('Subtitles'), children: [ SimpleDialogOption( onPressed: () => controller.setSpuTrack(-1), child: Text('Disabled'), ), ...subs.entries.map((e) => SimpleDialogOption( onPressed: () => controller.setSpuTrack(e.key), child: Text(e.value), )), ], ), ); ``` -------------------------------- ### Preventing Not Initialized Exception Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Example of how to check if the controller is initialized before calling playback methods. ```dart if (!controller.value.isInitialized) { await controller.initialize(); } await controller.play(); ``` -------------------------------- ### Renderer Detached Event Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-events.md Example of handling the detached renderer event to log the lost device name and remove it from a list. ```dart case VlcRendererEventType.detached: print('Device lost: ${event.rendererName}'); // Remove from device list, stop casting if using this device ``` -------------------------------- ### HTTP Stream with Authentication Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-options.md Example for configuring HTTP stream options, including authentication details. ```dart final options = VlcPlayerOptions( http: VlcHttpOptions([ VlcHttpOptions.httpReconnect(true), VlcHttpOptions.httpUserAgent('MyApp/1.0'), VlcHttpOptions.httpReferrer('https://mysite.com'), ]), advanced: VlcAdvancedOptions([ VlcAdvancedOptions.networkCaching(3000), ]), ); final controller = VlcPlayerController.network( 'https://secure-stream.example.com/video.m3u8', options: options, ); ``` -------------------------------- ### Recover from uninitialized state Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Example of how to recover from an uninitialized state by attempting to play and catching the exception to initialize and play. ```dart // Method called before initialization try { await controller.play(); } on Exception catch (e) { // Initialize first await controller.initialize(); await controller.play(); } ``` -------------------------------- ### Preventing Zero Playback Speed Exception (Correct Usage) Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Example showing the correct way to pause playback instead of setting playback speed to zero. ```dart await controller.pause(); // Not: await controller.setPlaybackSpeed(0.0); ``` -------------------------------- ### Example for erroneous Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-value.md Example usage of the erroneous factory constructor. ```dart final errorValue = VlcPlayerValue.erroneous('Failed to load media'); ``` -------------------------------- ### VlcPlayerOptions get Method Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Method to retrieve the current options as a list of strings. ```dart List get() ``` -------------------------------- ### Configure caching and reconnection for network streams Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Example of configuring `VlcPlayerOptions` to enable network caching and HTTP reconnection for unreliable network streams. ```dart final options = VlcPlayerOptions( advanced: VlcAdvancedOptions([ VlcAdvancedOptions.networkCaching(3000), // 3s buffer ]), http: VlcHttpOptions([ VlcHttpOptions.httpReconnect(true), ]), ); final controller = VlcPlayerController.network( 'https://example.com/stream.m3u8', options: options, ); ``` -------------------------------- ### Using autoInitialize Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Demonstrates using the autoInitialize flag for automatic controller initialization. ```dart final controller = VlcPlayerController.network( url, autoInitialize: true, // Initializes automatically ); // initialization happens before any UI rendering ``` -------------------------------- ### copyWith() Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-value.md Example of using the copyWith method to update VlcPlayerValue. ```dart final updated = value.copyWith( isPlaying: true, position: Duration(seconds: 30), ); ``` -------------------------------- ### VlcPlayerController Initialization & Lifecycle Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Methods for initializing and disposing the VlcPlayerController. ```dart Future initialize() Future dispose() ``` -------------------------------- ### VlcSubtitleOptions Constructor Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Constructor for VlcSubtitleOptions, taking a list of string options. ```dart VlcSubtitleOptions(List options) ``` -------------------------------- ### stopRendererScanning Example Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of stopping renderer scanning within the dispose method. ```dart @override void dispose() { _controller.stopRendererScanning(); _controller.dispose(); super.dispose(); } ``` -------------------------------- ### Upgrade Instructions for Version 5.0 Source: https://github.com/solid-software/flutter_vlc_player/blob/master/README.md Steps to upgrade an existing Flutter project to version 5.0, including Swift migration for iOS. ```bash git clean -xdf ``` ```bash flutter create -i swift . ``` -------------------------------- ### VlcVideoOptions Constructor Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Constructor for VlcVideoOptions, taking a list of string options. ```dart VlcVideoOptions(List options) ``` -------------------------------- ### VlcAudioOptions Constructor Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Constructor for VlcAudioOptions, taking a list of string options. ```dart VlcAudioOptions(List options) ``` -------------------------------- ### VlcPlayerController Media Source Management Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Methods for setting media sources from different origins. ```dart Future setMediaFromAsset( String dataSource, { String? package, bool? autoPlay, HwAcc? hwAcc, } ) Future setMediaFromNetwork( String dataSource, { bool? autoPlay, HwAcc? hwAcc, } ) Future setMediaFromFile( File file, { bool? autoPlay, HwAcc? hwAcc, } ) ``` -------------------------------- ### VlcStreamOutputOptions Constructor Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Constructor for VlcStreamOutputOptions, taking a list of string options. ```dart VlcStreamOutputOptions(List options) ``` -------------------------------- ### Clean the repo Source: https://github.com/solid-software/flutter_vlc_player/blob/master/flutter_vlc_player/README.md Command to clean the repository before upgrading. ```git git clean -xdf ``` -------------------------------- ### VlcPlayerController Constructors Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Constructors for VlcPlayerController to initialize with different data sources. ```dart VlcPlayerController.asset( String dataSource, { bool autoInitialize = true, bool allowBackgroundPlayback = false, String? package, HwAcc hwAcc = HwAcc.auto, bool autoPlay = true, VlcPlayerOptions? options, } ) VlcPlayerController.network( String dataSource, { bool autoInitialize = true, bool allowBackgroundPlayback = false, HwAcc hwAcc = HwAcc.auto, bool autoPlay = true, VlcPlayerOptions? options, } ) VlcPlayerController.file( File file, { bool autoInitialize = true, bool allowBackgroundPlayback = true, HwAcc hwAcc = HwAcc.auto, bool autoPlay = true, VlcPlayerOptions? options, } ) ``` -------------------------------- ### getVideoTracks() Signature Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Signature for getting a map of all video tracks. ```dart Future> getVideoTracks() ``` -------------------------------- ### getAudioDelay() Signature Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Signature for getting the current audio delay. ```dart Future getAudioDelay() ``` -------------------------------- ### Enable verbose VLC logging Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Add raw options to enable very verbose logging for the VLC player. ```dart final options = VlcPlayerOptions( extras: ['--vvv'], // Very verbose ); ``` -------------------------------- ### getAudioTracks() Signature Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Signature for getting a map of all audio tracks. ```dart Future> getAudioTracks() ``` -------------------------------- ### getVideoTracksCount() Signature Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Signature for getting the number of available video tracks. ```dart Future getVideoTracksCount() ``` -------------------------------- ### VlcPlayerController Audio Track Management Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Methods for managing audio tracks. ```dart Future getAudioTracksCount() Future> getAudioTracks() Future getAudioTrack() Future setAudioTrack(int audioTrackNumber) Future setAudioDelay(int audioDelay) Future getAudioDelay() ``` -------------------------------- ### VlcPlayerController Additional Audio Sources Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Methods for adding external audio sources. ```dart Future addAudioFromNetwork( String dataSource, { bool? isSelected, } ) Future addAudioFromFile( File file, { bool? isSelected, } ) ``` -------------------------------- ### getAudioTracksCount() Signature Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Signature for getting the number of available audio tracks. ```dart Future getAudioTracksCount() ``` -------------------------------- ### Handle initialization errors Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Demonstrates how to handle potential errors during the initialization of the VlcPlayerController, such as network issues or invalid URLs. ```dart final controller = VlcPlayerController.network( 'https://example.com/video.mp4', ); try { await controller.initialize(); } catch (e) { print('Initialization failed: $e'); } controller.addListener(() { if (controller.value.hasError) { showDialog( context: context, builder: (_) => AlertDialog( title: Text('Playback Error'), content: Text(controller.value.errorDescription), actions: [ TextButton( onPressed: () => Navigator.pop(context), child: Text('OK'), ), ], ), ); } }); ``` -------------------------------- ### Set Looping Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of enabling video looping after playback reaches the end. ```dart await _controller.setLooping(true); ``` -------------------------------- ### VlcHttpOptions Constructor Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Constructor for VlcHttpOptions, taking a list of string options. ```dart VlcHttpOptions(List options) ``` -------------------------------- ### VlcVideoOptions Static Methods Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Static methods for configuring video frame dropping and skipping. ```dart static String dropLateFrames(bool enable) static String skipFrames(bool enable) ``` -------------------------------- ### VlcSubtitleThickness Constructor Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Constructor for VlcSubtitleThickness, taking an integer value. ```dart const VlcSubtitleThickness(int value) ``` -------------------------------- ### VlcSubtitleOptions Static Methods Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Static methods for configuring subtitle appearance, including font, size, color, and positioning. ```dart static String font(String font) static String monofont(String monofont) static String fontSize(int size) static String relativeFontSize(int size) static String boldStyle(bool enable) static String opacity(int opacity) static String color(VlcSubtitleColor color) static String textDirection(VlcSubtitleTextDirection direction) static String backgroundOpacity(int opacity) static String backgroundColor(VlcSubtitleColor color) static String outlineOpacity(int opacity) static String outlineColor(VlcSubtitleColor color) static String outlineThickness(VlcSubtitleThickness thickness) static String shadowOpacity(int opacity) static String shadowColor(VlcSubtitleColor color) static String shadowAngle(double angle) static String shadowDistance(double distance) static String yuvpRenderer(bool enable) ``` -------------------------------- ### Multiple Option Categories Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-options.md Example demonstrating the use of multiple option categories within VlcPlayerOptions. ```dart final options = VlcPlayerOptions( advanced: VlcAdvancedOptions([ VlcAdvancedOptions.networkCaching(2000), ]), audio: VlcAudioOptions([ VlcAudioOptions.audioTimeStretch(true), ]), video: VlcVideoOptions([ VlcVideoOptions.dropLateFrames(true), ]), subtitle: VlcSubtitleOptions([ VlcSubtitleOptions.fontSize(28), VlcSubtitleOptions.color(VlcSubtitleColor.white), ]), ); ``` -------------------------------- ### VlcRtpOptions Static Method Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Static method for enabling RTP over RTSP. ```dart static String rtpOverRtsp(bool enable) ``` -------------------------------- ### iOS Info.plist Permissions Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md XML configuration for Info.plist to enable arbitrary loads and Chromecast support on iOS. ```xml NSAppTransportSecurity NSAllowsArbitraryLoads NSLocalNetworkUsageDescription Used to search for chromecast devices NSBonjourServices _googlecast._tcp ``` -------------------------------- ### getVideoTrack() Signature Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Signature for getting the currently active video track index. ```dart Future getVideoTrack() ``` -------------------------------- ### getAudioTrack() Signature Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Signature for getting the currently active audio track index. ```dart Future getAudioTrack() ``` -------------------------------- ### Dispose VlcPlayerController Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of disposing the VlcPlayerController within a StatefulWidget's dispose method. ```dart @override void dispose() { _controller.dispose(); super.dispose(); } ``` -------------------------------- ### VlcSubtitleThickness Static Constants Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Predefined static constants for subtitle thickness. ```dart static const VlcSubtitleThickness none static const VlcSubtitleThickness thin static const VlcSubtitleThickness normal static const VlcSubtitleThickness thick ``` -------------------------------- ### Disposing and Reinitializing Controller Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Illustrates the correct way to dispose and reinitialize a controller, emphasizing creating a new instance instead of reusing a disposed one. ```dart // Do NOT do this: await _controller.dispose(); await _controller.initialize(); // ERROR // Do THIS instead: await _controller.dispose(); _controller = VlcPlayerController.network(url); await _controller.initialize(); ``` -------------------------------- ### Add OnRendererEventListener Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Example of adding a listener to handle renderer events, such as Chromecast device attachment. ```dart _controller.addOnRendererEventListener((eventType, id, name) { if (eventType == VlcRendererEventType.attached) { print('Renderer attached: $name'); } }); ``` -------------------------------- ### Listen for error events Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Example of adding a listener to the controller to detect and log error events. ```dart controller.addListener(() { if (controller.value.hasError) { print('Error: ${controller.value.errorDescription}'); } }); ``` -------------------------------- ### VlcPlayerController.file Constructor Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/api-reference/vlc-player-controller.md Creates a controller for a video file on the local filesystem. ```dart VlcPlayerController.file( File file, { bool autoInitialize = true, bool allowBackgroundPlayback = true, HwAcc hwAcc = HwAcc.auto, bool autoPlay = true, VlcPlayerOptions? options, @Deprecated VoidCallback? onInit, @Deprecated RendererCallback? onRendererHandler, } ) ``` -------------------------------- ### Monitor hasError property Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Example of monitoring the `hasError` property of `VlcPlayerValue` to display error descriptions. ```dart ValueListenableBuilder( valueListenable: controller, builder: (context, value, _) { if (value.hasError) { return Text('Error: ${value.errorDescription}'); } return VlcPlayer(controller: controller, aspectRatio: 16/9); }, ) ``` -------------------------------- ### Preventing Zero Playback Speed Exception Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Example demonstrating an invalid call to setPlaybackSpeed with 0.0. ```dart await controller.setPlaybackSpeed(0.0); // ERROR ``` -------------------------------- ### VlcRtpOptions Constructor Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/method-signatures.md Constructor for VlcRtpOptions, taking a list of string options. ```dart VlcRtpOptions(List options) ``` -------------------------------- ### Recording Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/README.md Capture video playback to a file by starting and stopping the recording process. ```dart // Start recording await controller.startRecording('/sdcard/Movies'); // ... media plays ... // Stop and get file path await controller.stopRecording(); final path = controller.value.recordPath; ``` -------------------------------- ### Android build.gradle Packaging Options Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/configuration.md Groovy configuration for android/app/build.gradle to handle packaging options for shared libraries. ```groovy android { packagingOptions { pickFirst 'lib/**/libc++_shared.so' } } ``` -------------------------------- ### Preventing Negative Playback Speed Exception Source: https://github.com/solid-software/flutter_vlc_player/blob/master/_autodocs/errors.md Example demonstrating an invalid call to setPlaybackSpeed with a negative value. ```dart await controller.setPlaybackSpeed(-1.5); // ERROR ```