### Install Dependencies Source: https://github.com/jhomlala/betterplayer/blob/master/docs/install.md Run 'flutter pub get' to install the project dependencies after updating pubspec.yaml. ```bash $ flutter pub get ``` -------------------------------- ### Advanced Player Setup with Controller Source: https://github.com/jhomlala/betterplayer/blob/master/docs/generalplayerusage.md Initialize BetterPlayerDataSource and BetterPlayerController in initState for more control over video playback. This allows for dynamic changes to video source, playback controls, and more. ```dart BetterPlayerController _betterPlayerController; @override void initState() { super.initState(); BetterPlayerDataSource betterPlayerDataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"); _betterPlayerController = BetterPlayerController( BetterPlayerConfiguration(), betterPlayerDataSource: betterPlayerDataSource); } ``` ```dart @override Widget build(BuildContext context) { return AspectRatio( aspectRatio: 16 / 9, child: BetterPlayer( controller: _betterPlayerController, ), ); } ``` -------------------------------- ### BetterPlayer Widget Setup for PiP Source: https://github.com/jhomlala/betterplayer/blob/master/docs/pictureinpictureconfiguration.md This snippet shows how to integrate the BetterPlayer widget with a GlobalKey, which is necessary for enabling Picture in Picture mode. ```dart GlobalKey _betterPlayerKey = GlobalKey(); ... AspectRatio( aspectRatio: 16 / 9, child: BetterPlayer( controller: _betterPlayerController, key: _betterPlayerKey, ), ), ``` -------------------------------- ### Setup Video with Multiple Resolutions Source: https://github.com/jhomlala/betterplayer/blob/master/docs/resolutionsofvideo.md Configure video playback with different quality options. This is intended for standard video files and requires the 'resolutions' parameter to be set in the data source. ```dart var dataSource = BetterPlayerDataSource(BetterPlayerDataSourceType.network, "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4", resolutions: { "LOW": "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4", "MEDIUM": "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_640_3MG.mp4", "LARGE": "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_1280_10MG.mp4", "EXTRA_LARGE": "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_1920_18MG.mp4" }); ``` -------------------------------- ### Network Data Source Example Source: https://github.com/jhomlala/betterplayer/blob/master/docs/datasourceconfiguration.md Defines a network data source for a video, including custom subtitles and headers. Ensure the directory path for subtitles is correctly resolved. ```dart var dataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4", subtitles: BetterPlayerSubtitlesSource( type: BetterPlayerSubtitlesSourceType.file, url: "${directory.path}/example_subtitles.srt", ), headers: {"header":"my_custom_header"} ); ``` -------------------------------- ### Basic BetterPlayerListVideoPlayer Setup Source: https://github.com/jhomlala/betterplayer/blob/master/docs/listplayerusage.md This snippet shows how to initialize BetterPlayerListVideoPlayer with a network data source and set the playFraction for automatic playback. The playFraction determines the percentage of the video that must be visible on screen to trigger playback. ```dart @override Widget build(BuildContext context) { return AspectRatio( aspectRatio: 16 / 9, child: BetterPlayerListVideoPlayer( BetterPlayerDataSource( BetterPlayerDataSourceType.network, videoListData.videoUrl), key: Key(videoListData.hashCode.toString()), playFraction: 0.8, ), ); } ``` -------------------------------- ### Initialize Player with Custom Controls Configuration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/controlsconfiguration.md Configure player controls by passing a BetterPlayerControlsConfiguration instance to BetterPlayerConfiguration during initialization. This example sets custom text and icon colors. ```dart var betterPlayerConfiguration = BetterPlayerConfiguration( controlsConfiguration: BetterPlayerControlsConfiguration( textColor: Colors.black, iconsColor: Colors.black, ), ); ``` -------------------------------- ### Start Pre-Caching Video Source: https://github.com/jhomlala/betterplayer/blob/master/docs/cacheconfiguration.md Initiate pre-caching for a specified BetterPlayerDataSource before playing the video. This is useful for ensuring smooth playback by downloading content in advance. ```dart betterPlayerController.preCache(_betterPlayerDataSource); ``` -------------------------------- ### ClearKey DRM Configuration (Android) Source: https://github.com/jhomlala/betterplayer/blob/master/docs/drmconfiguration.md Configure ClearKey DRM for Android. This example shows how to generate the ClearKey configuration using key IDs and values. ```dart var _clearKeyDataSourceFile = BetterPlayerDataSource( BetterPlayerDataSourceType.file, await Utils.getFileUrl(Constants.fileTestVideoEncryptUrl), drmConfiguration: BetterPlayerDrmConfiguration( drmType: BetterPlayerDrmType.clearKey, clearKey: BetterPlayerClearKeyUtils.generate({ "f3c5e0361e6654b28f8049c778b23946": "a4631a153a443df9eed0593043db7519", "abba271e8bcf552bbd2e86a434a9a5d9": "69eaa802a6763af979e8d1940fb88392" })), ); ``` -------------------------------- ### Basic Network Video Playback Source: https://github.com/jhomlala/betterplayer/blob/master/docs/generalplayerusage.md Use BetterPlayer.network for quick setup of video playback from a URL with basic configuration. Ensures a 16:9 aspect ratio. ```dart BetterPlayer.network(url, configuration) ``` ```dart BetterPlayer.file(url, configuration) ``` ```dart @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Example player"), ), body: AspectRatio( aspectRatio: 16 / 9, child: BetterPlayer.network( "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4", betterPlayerConfiguration: BetterPlayerConfiguration( aspectRatio: 16 / 9, ), ), ), ); } ``` -------------------------------- ### Basic Network Video Playback Source: https://github.com/jhomlala/betterplayer/blob/master/docs/basicusage.md Use BetterPlayer.network for quick setup of video playback from a URL with basic configuration. Ensures the video maintains a 16:9 aspect ratio. ```dart BetterPlayer.network("https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4", betterPlayerConfiguration: BetterPlayerConfiguration( aspectRatio: 16 / 9, )) ``` -------------------------------- ### Using BetterPlayerMultipleGestureDetector Source: https://github.com/jhomlala/betterplayer/blob/master/docs/multiplegesturedetector.md Wrap the BetterPlayer widget with BetterPlayerMultipleGestureDetector to handle multiple gestures. This example shows how to implement an onTap gesture. ```dart BetterPlayerMultipleGestureDetector( child: AspectRatio( aspectRatio: 16 / 9, child: BetterPlayer(controller: _betterPlayerController), ), onTap: () { print("Tap!"); }, ), ``` -------------------------------- ### BetterPlayerBufferingConfiguration Options Source: https://github.com/jhomlala/betterplayer/blob/master/docs/bufferingconfiguration.md Defines the parameters available for customizing buffer durations in BetterPlayer. These include minimum buffer, maximum buffer, buffer for playback start, and buffer for playback after rebuffer. ```dart ///The default minimum duration of media that the player will attempt to ///ensure is buffered at all times, in milliseconds. final int minBufferMs; ///The default maximum duration of media that the player will attempt to ///buffer, in milliseconds. final int maxBufferMs; ///The default duration of media that must be buffered for playback to start ///or resume following a user action such as a seek, in milliseconds. final int bufferForPlaybackMs; ///The default duration of media that must be buffered for playback to resume ///after a rebuffer, in milliseconds. A rebuffer is defined to be caused by ///buffer depletion rather than a user action. final int bufferForPlaybackAfterRebufferMs; ``` -------------------------------- ### Update Controls Configuration at Runtime Source: https://github.com/jhomlala/betterplayer/blob/master/docs/controlsconfiguration.md Modify player controls configuration dynamically after initialization using the setBetterPlayerControlsConfiguration method of BetterPlayerController. This example changes the overflow modal color. ```dart _betterPlayerController.setBetterPlayerControlsConfiguration( BetterPlayerControlsConfiguration( overflowModalColor: Colors.amberAccent), ); ``` -------------------------------- ### Player Visibility Changed Behavior Example Source: https://github.com/jhomlala/betterplayer/blob/master/docs/playerbehavioronvisibilitychange.md This Dart code snippet demonstrates how to manage player playback (play/pause) based on the visible fraction of the player widget. It's useful for players within lists where visibility is dynamic. Ensure `_betterPlayerController` is initialized and handle disposal states (`_isDisposing`). ```dart void onVisibilityChanged(double visibleFraction) async { bool isPlaying = await _betterPlayerController.isPlaying(); bool initialized = _betterPlayerController.isVideoInitialized(); if (visibleFraction >= widget.playFraction) { if (widget.autoPlay && initialized && !isPlaying && !_isDisposing) { _betterPlayerController.play(); } } else { if (widget.autoPause && initialized && isPlaying && !_isDisposing) { _betterPlayerController.pause(); } } } ``` -------------------------------- ### Initialize BetterPlayerPlaylistConfiguration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/playlistconfiguration.md Instantiate BetterPlayerPlaylistConfiguration to customize playlist behavior. Set loopVideos to false and nextVideoDelay to 5000 milliseconds. ```dart var betterPlayerPlaylistConfiguration = BetterPlayerPlaylistConfiguration( loopVideos: false, nextVideoDelay: Duration(milliseconds: 5000) ); ``` -------------------------------- ### Initialize BetterPlayerController and DataSource Source: https://github.com/jhomlala/betterplayer/blob/master/docs/basicusage.md Set up BetterPlayerDataSource and BetterPlayerController in the initState method for more advanced configuration options. This allows for control over video source type, URL, and subtitles. ```dart BetterPlayerController _betterPlayerController; @override void initState() { super.initState(); BetterPlayerDataSource betterPlayerDataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"); _betterPlayerController = BetterPlayerController( BetterPlayerConfiguration(), betterPlayerDataSource: betterPlayerDataSource); } ``` -------------------------------- ### Create Playlist Data Sources Source: https://github.com/jhomlala/betterplayer/blob/master/docs/playlistplayerusage.md Creates a list of BetterPlayerDataSource objects for network videos. This is the first step to setting up a playlist. ```dart List createDataSet() { List dataSourceList = List(); dataSourceList.add( BetterPlayerDataSource( BetterPlayerDataSourceType.network, "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4", ), ); dataSourceList.add( BetterPlayerDataSource(BetterPlayerDataSourceType.network, "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"), ); dataSourceList.add( BetterPlayerDataSource(BetterPlayerDataSourceType.network, "http://sample.vodobox.com/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8"), ); return dataSourceList; } ``` -------------------------------- ### Create BetterPlayerConfiguration Instance Source: https://github.com/jhomlala/betterplayer/blob/master/docs/generalconfiguration.md Instantiate BetterPlayerConfiguration to set general player options like autoplay, looping, and fullscreen behavior. This configuration object is used when creating the BetterPlayerController. ```dart var betterPlayerConfiguration = BetterPlayerConfiguration( autoPlay: true, looping: true, fullScreenByDefault: true, ); ``` -------------------------------- ### Initialize BetterPlayerPlaylist Widget Source: https://github.com/jhomlala/betterplayer/blob/master/docs/playlistplayerusage.md Initializes the BetterPlayerPlaylist widget with a list of data sources and default configurations. This widget plays videos sequentially. ```dart @override Widget build(BuildContext context) { return AspectRatio( aspectRatio: 16 / 9, child: BetterPlayerPlaylist( betterPlayerConfiguration: BetterPlayerConfiguration(), betterPlayerPlaylistConfiguration: const BetterPlayerPlaylistConfiguration(), betterPlayerDataSourceList: dataSourceList), ); } ``` -------------------------------- ### Check Data Source Load Status Source: https://github.com/jhomlala/betterplayer/blob/master/docs/sourceload.md Use the `.then()` and `.catchError()` methods on the future returned by `setupDataSource` to determine if the data source loaded successfully or if an error occurred, such as an invalid URL. ```dart betterPlayerController!.setupDataSource(source) .then((response) { // Source loaded successfully videoLoading = false; }) .catchError((error) async { // Source did not load, url might be invalid inspect(error); }); ``` -------------------------------- ### Docsify Configuration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/index.html Configuration object for the Docsify documentation generator. This sets up the name, repository link, sidebar loading, cover page, search functionality, and theme. ```javascript window.$docsify = { name: 'Better Player', repo: "https://github.com/jhomlala/betterplayer/", homepage: "home.md", loadSidebar: true, coverpage: true, search: { paths: "auto", placeholder: "Search", noData: "No Results.", depth: 6, }, darklightTheme: { defaultTheme: "light", }, } ``` -------------------------------- ### Add Dependency to pubspec.yaml Source: https://github.com/jhomlala/betterplayer/blob/master/docs/install.md Add the Better Player dependency to your project's pubspec.yaml file. ```yaml dependencies: better_player: ^0.0.84 ``` -------------------------------- ### Fairplay DRM Configuration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/drmconfiguration.md Configure Fairplay DRM for iOS. Requires a certificate URL and a license URL. ```dart BetterPlayerDataSource _fairplayDataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, Constants.fairplayHlsUrl, drmConfiguration: BetterPlayerDrmConfiguration( drmType: BetterPlayerDrmType.fairplay, certificateUrl: Constants.fairplayCertificateUrl, licenseUrl: Constants.fairplayLicenseUrl, ), ); ``` -------------------------------- ### Configure Cache for Network Data Source Source: https://github.com/jhomlala/betterplayer/blob/master/docs/cacheconfiguration.md Define cache configuration with BetterPlayerCacheConfiguration for a given data source. Cache works only for network data sources. Use this in BetterPlayerDataSource. ```dart BetterPlayerDataSource _betterPlayerDataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, Constants.elephantDreamVideoUrl, cacheConfiguration: BetterPlayerCacheConfiguration( useCache: true, preCacheSize: 10 * 1024 * 1024, maxCacheSize: 10 * 1024 * 1024, maxCacheFileSize: 10 * 1024 * 1024, ///Android only option to use cached video between app sessions key: "testCacheKey", ), ); ``` -------------------------------- ### Subtitles Configuration Options Source: https://github.com/jhomlala/betterplayer/blob/master/docs/subtitlesconfiguration.md Defines the available configuration options for `BetterPlayerSubtitlesSource`, including type, name, URLs, content, selection, headers, and ASMS-specific settings. ```dart ///Source type final BetterPlayerSubtitlesSourceType? type; ///Name of the subtitles, default value is "Default subtitles" final String? name; ///Url of the subtitles, used with file or network subtitles final List? urls; ///Content of subtitles, used when type is memory final String? content; ///Subtitles selected by default, without user interaction final bool? selectedByDefault; ///Additional headers used in HTTP request. Works only for /// [BetterPlayerSubtitlesSourceType.memory] source type. final Map? headers; ///Is ASMS segmented source (more than 1 subtitle file). This shouldn't be /// configured manually. final bool? asmsIsSegmented; ///Max. time between segments in milliseconds. This shouldn't be configured /// manually. final int? asmsSegmentsTime; ///List of segments (start,end,url of the segment). This shouldn't be /// configured manually. final List? asmsSegments; ``` -------------------------------- ### Subtitle Appearance Options Source: https://github.com/jhomlala/betterplayer/blob/master/docs/subtitlesconfiguration.md Lists the available configuration options for `BetterPlayerSubtitlesConfiguration`, including font size, color, outline, padding, alignment, and background color. ```dart ///Subtitle font size final double fontSize; ///Subtitle font color final Color fontColor; ///Enable outline (border) of the text final bool outlineEnabled; ///Color of the outline stroke final Color outlineColor; ///Outline stroke size final double outlineSize; ///Font family of the subtitle final String fontFamily; ///Left padding of the subtitle final double leftPadding; ///Right padding of the subtitle final double rightPadding; ///Bottom padding of the subtitle final double bottomPadding; ///Alignment of the subtitle final Alignment alignment; ///Background color of the subtitle final Color backgroundColor; ///Subtitles selected by default, without user interaction final bool selectedByDefault; ``` -------------------------------- ### Token-based DRM Configuration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/drmconfiguration.md Use this for token-based DRM, commonly supported on Android and iOS. Ensure your token is correctly formatted. ```dart BetterPlayerDataSource dataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, "url", videoFormat: BetterPlayerVideoFormat.hls, drmConfiguration: BetterPlayerDrmConfiguration( drmType: BetterPlayerDrmType.token, token: "Bearer=token", ), ); ``` -------------------------------- ### Multiple Network Subtitles Configuration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/subtitlesconfiguration.md Configure multiple network subtitles for a single video by passing a list of `BetterPlayerSubtitlesSource` objects to the `subtitles` parameter. Each source can have a unique name. ```dart var dataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, "https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8", liveStream: false, useAsmsSubtitles: true, hlsTrackNames: ["Low quality", "Not so low quality", "Medium quality"], subtitles: [ BetterPlayerSubtitlesSource( type: BetterPlayerSubtitlesSourceType.network, name: "EN", urls: [ "https://dl.dropboxusercontent.com/s/71nzjo2ux3evxqk/example_subtitles.srt" ], ), BetterPlayerSubtitlesSource( type: BetterPlayerSubtitlesSourceType.network, name: "DE", urls: [ "https://dl.dropboxusercontent.com/s/71nzjo2ux3evxqk/example_subtitles.srt" ], ), ], ); ``` -------------------------------- ### Import Better Player Source: https://github.com/jhomlala/betterplayer/blob/master/docs/install.md Import the Better Player library into your Dart code. ```dart import 'package:better_player/better_player.dart'; ``` -------------------------------- ### Enable Mix with Others in Better Player Source: https://github.com/jhomlala/betterplayer/blob/master/docs/mixaudiowithothers.md Call this method to allow Better Player's audio to mix with other apps. The default value is false. ```dart betterPlayerController.setMixWithOthers(true) ``` -------------------------------- ### File Subtitles Configuration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/subtitlesconfiguration.md Configure file subtitles by providing a local file path to the SRT file within `BetterPlayerDataSource`. Ensure the `BetterPlayerDataSourceType` is set to `file`. ```dart var dataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.file, "${directory.path}/testvideo.mp4", subtitles: BetterPlayerSubtitlesSource.single( type: BetterPlayerSubtitlesSourceType.file, url: "${directory.path}/example_subtitles.srt", ), ); ``` -------------------------------- ### iOS Full Screen Rotation Configuration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/install.md Add this to your info.plist file to enable full-screen rotation support for Better Player on iOS. ```xml UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight ``` -------------------------------- ### Display BetterPlayer Widget Source: https://github.com/jhomlala/betterplayer/blob/master/docs/basicusage.md Render the BetterPlayer widget using the initialized controller, wrapped in an AspectRatio widget to maintain a 16:9 aspect ratio for the video display. ```dart @override Widget build(BuildContext context) { return AspectRatio( aspectRatio: 16 / 9, child: BetterPlayer( controller: _betterPlayerController, ), ); } ``` -------------------------------- ### ClearKey DRM XML Configuration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/drmconfiguration.md XML structure for ClearKey DRM configuration, used with MP4Box to encrypt video files. ```xml ``` -------------------------------- ### Network Subtitles Configuration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/subtitlesconfiguration.md Configure network subtitles by providing a URL to the SRT file within `BetterPlayerDataSource`. Ensure the `BetterPlayerDataSourceType` is set to `network`. ```dart var dataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4", subtitles: BetterPlayerSubtitlesSource.single( type: BetterPlayerSubtitlesSourceType.network, url: "https://dl.dropboxusercontent.com/s/71nzjo2ux3evxqk/example_subtitles.srt" ), ); ``` -------------------------------- ### Configure Buffering with BetterPlayerDataSource Source: https://github.com/jhomlala/betterplayer/blob/master/docs/bufferingconfiguration.md Use BetterPlayerBufferingConfiguration to set custom buffer durations within BetterPlayerDataSource. This configuration is currently only available on Android. ```dart BetterPlayerDataSource _betterPlayerDataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, Constants.elephantDreamVideoUrl, bufferingConfiguration: BetterPlayerBufferingConfiguration( minBufferMs: 50000, maxBufferMs: 13107200, bufferForPlaybackMs: 2500, bufferForPlaybackAfterRebufferMs: 5000, ), ); ``` -------------------------------- ### Enable Picture in Picture Mode Source: https://github.com/jhomlala/betterplayer/blob/master/docs/pictureinpictureconfiguration.md Call this method to activate Picture in Picture mode. It requires a GlobalKey associated with the BetterPlayer widget. ```dart _betterPlayerController.enablePictureInPicture(_betterPlayerKey); ``` -------------------------------- ### Override Aspect Ratio at Runtime Source: https://github.com/jhomlala/betterplayer/blob/master/docs/overriddenfit.md Use the `setOverriddenFit` method on the `betterPlayerController` to change the player's fit mode during playback. This is useful for adapting the video display to different screen sizes or user preferences. ```dart betterPlayerController.setOverriddenFit(BoxFit.contain); ``` -------------------------------- ### Manual Dispose Controller Source: https://github.com/jhomlala/betterplayer/blob/master/docs/manualdispose.md Call the `dispose()` method on the `BetterPlayerController` instance when it's no longer needed to free up resources. This is required when `autoDispose` is set to false. ```dart betterPlayerController.dispose(); ``` -------------------------------- ### Configure Player Notification Source: https://github.com/jhomlala/betterplayer/blob/master/docs/notificationconfiguration.md Use `BetterPlayerNotificationConfiguration` to enable and customize player notifications. Set parameters like title, author, and image URL. The `activityName` is used for Android to specify which activity to launch when the notification is clicked. ```dart BetterPlayerDataSource dataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, Constants.elephantDreamVideoUrl, notificationConfiguration: BetterPlayerNotificationConfiguration( showNotification: true, title: "Elephant dream", author: "Some author", imageUrl: "https://upload.wikimedia.org/wikipedia/commons/thumb/3/37/African_Bush_Elephant.jpg/1200px-African_Bush_Elephant.jpg", activityName: "MainActivity", ), ); ``` -------------------------------- ### Widevine DRM Configuration Source: https://github.com/jhomlala/betterplayer/blob/master/docs/drmconfiguration.md Configure Widevine DRM for Android. Requires a license URL and any necessary headers for the license server. ```dart BetterPlayerDataSource _widevineDataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, "url", drmConfiguration: BetterPlayerDrmConfiguration( drmType: BetterPlayerDrmType.widevine, licenseUrl:"licenseUrl", headers: {"header": "value"} ), ); ``` -------------------------------- ### Set Controls Always Visible Source: https://github.com/jhomlala/betterplayer/blob/master/docs/enabledisablecontrols.md Use this to ensure player controls remain visible and do not fade out. They will always be overlaid on the video. ```dart betterPlayerController.setControlsAlwaysVisible(true); ``` -------------------------------- ### Override Aspect Ratio at Runtime Source: https://github.com/jhomlala/betterplayer/blob/master/docs/overriddenaspectratio.md Use the `setOverriddenAspectRatio` method on the `betterPlayerController` to change the video's aspect ratio during playback. This allows for dynamic adjustments based on user interaction or content changes. ```dart betterPlayerController.setOverriddenAspectRatio(1.0); ``` -------------------------------- ### Customize Subtitle Appearance Source: https://github.com/jhomlala/betterplayer/blob/master/docs/subtitlesconfiguration.md Customize subtitle appearance by creating a `BetterPlayerSubtitlesConfiguration` instance and passing it to `BetterPlayerConfiguration`. This allows setting font size and color. ```dart var betterPlayerConfiguration = BetterPlayerConfiguration( subtitlesConfiguration: BetterPlayerSubtitlesConfiguration( fontSize: 20, fontColor: Colors.green, ), ); ``` -------------------------------- ### Check if Picture in Picture is Supported Source: https://github.com/jhomlala/betterplayer/blob/master/docs/pictureinpictureconfiguration.md Use this method to determine if the current device supports Picture in Picture mode. Errors will be printed to the console if the device does not meet the requirements. ```dart _betterPlayerController.isPictureInPictureSupported(); ``` -------------------------------- ### Provide Custom Translations for Better Player Source: https://github.com/jhomlala/betterplayer/blob/master/docs/translationsconfiguration.md Pass a list of `BetterPlayerTranslations` objects to the `translations` property of `BetterPlayerConfiguration` to customize player text for different languages. Ensure your app has localizations set up. ```dart translations: [ BetterPlayerTranslations( languageCode: "language_code for example pl", generalDefaultError: "translated text", generalNone: "translated text", generalDefault: "translated text", playlistLoadingNextVideo: "translated text", controlsLive: "translated text", controlsNextVideoIn: "translated text", overflowMenuPlaybackSpeed: "translated text", overflowMenuSubtitles: "translated text", overflowMenuQuality: "translated text", ), BetterPlayerTranslations( languageCode: "other language for example cz", generalDefaultError: "translated text", generalNone: "translated text", generalDefault: "translated text", playlistLoadingNextVideo: "translated text", controlsLive: "translated text", controlsNextVideoIn: "translated text", overflowMenuPlaybackSpeed: "translated text", overflowMenuSubtitles: "translated text", overflowMenuQuality: "translated text", ), ], ``` -------------------------------- ### Add Event Listener to BetterPlayerController Source: https://github.com/jhomlala/betterplayer/blob/master/docs/events.md Listen for various Better Player events by adding a listener to the BetterPlayerController. The listener is automatically removed on dispose. ```dart _betterPlayerController.addEventsListener((event){ print("Better player event: ${event.betterPlayerEventType}"); }); ``` -------------------------------- ### Set Overridden Duration for Network Video Source: https://github.com/jhomlala/betterplayer/blob/master/docs/overriddenduration.md Use `overriddenDuration` to play only a specific portion of a network video. This is useful for segmenting long videos. ```dart BetterPlayerDataSource dataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, Constants.elephantDreamVideoUrl, ///Play only 10 seconds of this video. overriddenDuration: const Duration(seconds: 10), ); ``` -------------------------------- ### Stop Pre-Caching Source: https://github.com/jhomlala/betterplayer/blob/master/docs/cacheconfiguration.md Stop any ongoing pre-caching operation for a given BetterPlayerDataSource. This can be used to free up resources or if the user navigates away from the video. ```dart betterPlayerController.stopPreCache(_betterPlayerDataSource); ``` -------------------------------- ### Add Custom Element to Overflow Menu Source: https://github.com/jhomlala/betterplayer/blob/master/docs/customelementinoverflowmenu.md Use `BetterPlayerControlsConfiguration` to define custom items for the overflow menu. Each item requires an icon, a title, and an action callback. ```dart controlsConfiguration: BetterPlayerControlsConfiguration( overflowMenuCustomItems: [ BetterPlayerOverflowMenuItem( Icons.account_circle_rounded, "Custom element", () => print("Click!"), ) ], ), ``` -------------------------------- ### Clear All Cached Data Source: https://github.com/jhomlala/betterplayer/blob/master/docs/cacheconfiguration.md Call this method on the BetterPlayerController to clear all cached video data. ```dart betterPlayerController.clearCache(); ``` -------------------------------- ### Disable Auto Dispose Source: https://github.com/jhomlala/betterplayer/blob/master/docs/manualdispose.md Set `autoDispose` to false in `BetterPlayerConfiguration` to prevent the controller from being disposed automatically when the widget is removed. ```dart BetterPlayerConfiguration betterPlayerConfiguration = BetterPlayerConfiguration( autoDispose: false, ); ``` -------------------------------- ### Disable Player Controls Source: https://github.com/jhomlala/betterplayer/blob/master/docs/enabledisablecontrols.md Use this to make the player controls permanently disabled. This prevents user interaction with the controls. ```dart betterPlayerController.setControlsEnabled(false); ``` -------------------------------- ### Disable Picture in Picture Mode Source: https://github.com/jhomlala/betterplayer/blob/master/docs/pictureinpictureconfiguration.md Use this method to exit Picture in Picture mode and return to the standard video player view. ```dart betterPlayerController.disablePictureInPicture(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.