http
and ending with .m3u8
) are popular.TXVodPlayerController _controller = TXVodPlayerController();
// Listen for the video width and height change and set an appropriate aspect ratio. You can also customize the aspect ratio, and the video texture will be stretched proportionally_controller.onPlayerNetStatusBroadcast.listen((event) async {double w = (event["VIDEO_WIDTH"]).toDouble();double h = (event["VIDEO_HEIGHT"]).toDouble();if (w > 0 && h > 0) {setState(() {_aspectRatio = 1.0 * w / h;});}});
@overrideWidget build(BuildContext context) {return Container(decoration: BoxDecoration(image: DecorationImage(image: AssetImage("images/ic_new_vod_bg.png"),fit: BoxFit.cover,)),child: Scaffold(backgroundColor: Colors.transparent,appBar: AppBar(backgroundColor: Colors.transparent,title: const Text('VOD'),),body: SafeArea(child: Container(height: 150,color: Colors.black,child: Center(child: _aspectRatio > 0? AspectRatio(aspectRatio: _aspectRatio,child: TXPlayerVideo(controller: _controller),) : Container(),),))));}
// Initialize the player and assign the shared textureawait _controller.initialize();
TXVodPlayerController
will internally recognize the playback protocol automatically. You only need to pass in your playback URL to the startVodPlay
function.// Play back the video resourceString _url ="http://1400329073.vod2.myqcloud.com/d62d88a7vodtranscq1400329073/59c68fe75285890800381567412/adp.10.m3u8";await _controller.startVodPlay(_url);
// `psign` is a player signature. For more information on the signature and how to generate it, see [Player Signature](https://www.tencentcloud.com/document/product/266/38099).TXPlayInfoParams params = TXPlayInfoParams(appId: 1252463788,fileId: "4564972819220421305", psign: "psignxxxxxxx");await _controller.startVodPlayWithParams(params);
FileId
, and the player will request the backend for the real playback URL. If the network is abnormal or the FileId
doesn't exist, the TXLiveConstants.PLAY_ERR_GET_PLAYINFO_FAIL
event will be received; otherwise, TXLiveConstants.PLAY_EVT_GET_PLAYINFO_SUCC
will be received, indicating that the request succeeded.startVodPlay
. This can prevent memory leak and screen flashing issues.@overridevoid dispose() {_controller.dispose();super.dispose();}
// Start playback_controller.startVodPlay(url)
// Pause the video_controller.pause();
// Resume the video_controller.resume();
// Stop the video_controller.stopPlay(true);
// Release the controller_controller.dispose();
seek
can be called to start playback at the specified position. The Player SDK supports accurate seek.double time = 600; // The value is of `double` type and is in seconds.// Adjust the playback progress_controller.seek(time);
int pdtTimeMs = 600; // Unit is milliseconds_controller.seekToPdtTime(time);
startVodPlay
for the first time.double startTimeInSecond = 60; // Unit: Second._controller.setStartTime(startTimeInSecond); // Set the playback start time_controller.startVodPlay(url);
setRate
API to set the VOD playback speed, such as 0.5x, 1.0x, 1.2x, and 2x speed.// Set playback at 1.2X rate_controller.setRate(1.2);
// Set playback loop_controller.setLoop(true);// Get the current playback loop status_controller.isLoop();
// Mute or unmute the player. true: Mute; false: Unmute_controller.setMute(true);
autoPlay
is set to NO
, the player will load the video normally but will not immediately start playing it back.resume
API will be called to start video playback._controller.setAutoPlay(false); // Set manual playback_controller.startVodPlay(url); // The video will be loaded after `startVodPlay` is called and won't be played back automatically after being loaded successfully.// ......// Display the ad on the player UI// ......_controller.resume(); // Call `resume` to start playing back the video after the ad display ends
headers
in TXVodPlayConfig
can be used to set HTTP request headers, such as the Referer
field commonly used to prevent the URL from being copied arbitrarily (Tencent Cloud provides a more secure signature-based hotlink protection solution) and the Cookie
field for client authentication.FTXVodPlayConfig playConfig = FTXVodPlayConfig();Map<String, String> httpHeaders = {'Referer': 'Referer Content'};playConfig.headers = httpHeaders;_controller.setConfig(playConfig);
_controller.stopPlay(true);_controller.enableHardwareDecode(true);_controller.startVodPlay(url);
List _supportedBitrates = (await _controller.getSupportedBitrates())!;; // Get the array of multiple bitratesint index = _supportedBitrates[i]; // Specify the subscript of the bitrate of the stream to be played back_controller.setBitrateIndex(index); // Switch to the stream at the target bitrate and definition
_controller.setBitrateIndex(int)
at any time to switch the bitrate. During switch, the data of another stream will be pulled. The SDK is optimized for Tencent Cloud multi-bitrate files to implement smooth switch._controller.setBitrateIndex(-1); // Pass in `-1` for the `index` parameter
_controller.setBitrateIndex(int)
at any time to switch to another bitrate. After the switch, adaptive bitrate streaming will be disabled.FTXVodPlayConfig playConfig = FTXVodPlayConfig();/// If it is set to `true`, the bitrate can be switched smoothly. If it is set to `false`, multi-bitrate URLs are opened faster.playConfig.smoothSwitchBitrate = true;_controller.setConfig(playConfig);
onPlayerEventBroadcast
API to listen on player events, and the progress notification will be called back to your application through the PLAY_EVT_PLAY_PROGRESS event._controller.onPlayerEventBroadcast.listen((event) async {if(event["event"] == TXVodPlayEvent.PLAY_EVT_PLAY_PROGRESS) {// For more information, see the native SDK status codes of iOS or Android.// Playable duration, i.e., loading progress, in millisecondsdouble playableDuration = event[TXVodPlayEvent.EVT_PLAYABLE_DURATION_MS].toDouble();// Playback progress in secondsint progress = event[TXVodPlayEvent.EVT_PLAY_PROGRESS].toInt();// Total video duration in secondsint duration = event[TXVodPlayEvent.EVT_PLAY_DURATION].toInt();}});
onPlayerNetStatusBroadcast
API to listen on the player network status such as NET_STATUS_NET_SPEED
._controller.onPlayerNetStatusBroadcast.listen((event) {(event[TXVodNetEvent.NET_STATUS_NET_SPEED]).toDouble();});
NET_STATUS_VIDEO_WIDTH
and NET_STATUS_VIDEO_HEIGHT
of onPlayerNetStatusBroadcast
to get the video width and height.getWidth()
and getHeight()
to get the current video width and height after receiving the PLAY_EVT_VOD_PLAY_PREPARED
event callback from the player._controller.onPlayerNetStatusBroadcast.listen((event) {double w = (event[TXVodNetEvent.NET_STATUS_VIDEO_WIDTH]).toDouble();double h = (event[TXVodNetEvent.NET_STATUS_VIDEO_HEIGHT]).toDouble();});// Get the video width and height. The values can be returned only after the `PLAY_EVT_VOD_PLAY_PREPARED` event callback is received from the player_controller.getWidth();_controller.getHeight();
FTXVodPlayConfig playConfig = FTXVodPlayConfig();playConfig.maxBufferSize = 10; /// The maximum buffer size during playback in MB_controller.setConfig(playConfig);
// Set the global cache directory and cache size in MB of the playback engineSuperPlayerPlugin.setGlobalMaxCacheSize(200);// Set the global cache directory of the playback engineSuperPlayerPlugin.setGlobalCacheFolderPath("postfixPath");
// Add external subtitles, pass in the subtitle url, subtitle name, subtitle type, it is recommended to add it before starting the playercontroller.addSubtitleSource("https://mediacloud-76607.gzc.vod.tencent-cloud.com/DemoResource/subtitleVTT.vtt", "subtitleName", TXVodPlayEvent.VOD_PLAY_MIMETYPE_TEXT_SRT)// After starting to play the video, monitor the subtitle text content callback_controller.onPlayerEventBroadcast.listen((event) async {if(event["event"] == TXVodPlayEvent.EVENT_SUBTITLE_DATA) {// Subtitle text content, can be used for displayString subtitleDataStr = event[TXVodPlayEvent.EXTRA_SUBTITLE_DATA] ?? "";}});
// After starting to play the video, select the added external subtitles and call it after receiving the VOD_PLAY_EVT_VOD_PLAY_PREPARED event._controller.onPlayerEventBroadcast.listen((event) async {if(event["event"] == TXVodPlayEvent.PLAY_EVT_VOD_PLAY_PREPARED) {List<TXTrackInfo> trackInfoList = await _vodPlayerController.getSubtitleTrackInfo();for (TXTrackInfo tempInfo in trackInfoList) {if(tempInfo.name == "subtitleName") {//Select subtitles_vodPlayerController.selectTrack(tempInfo.trackIndex);} else {// If other subtitles are not needed, perform deselectTrack_vodPlayerController.deselectTrack(tempInfo.trackIndex);}}}});// If necessary, you can listen for track switching messages_controller.onPlayerEventBroadcast.listen((event) async {if(event["event"] == TXVodPlayEvent.VOD_PLAY_EVT_SELECT_TRACK_COMPLETE) {int trackIndex = event[TXVodPlayEvent.EVT_KEY_SELECT_TRACK_INDEX];int errorCode = event[TXVodPlayEvent.EVT_KEY_SELECT_TRACK_ERROR_CODE];}});
// After starting to play the video, monitor the subtitle text content callback_controller.onPlayerEventBroadcast.listen((event) async {if(event["event"] == TXVodPlayEvent.EVENT_SUBTITLE_DATA) {// Subtitle text content, can be used for displayString subtitleDataStr = event[TXVodPlayEvent.EXTRA_SUBTITLE_DATA] ?? "";}});
// Return the audio track information listList<TXTrackInfo> trackInfoList = await _vodPlayerController.getAudioTrackInfo();for (TXTrackInfo tempInfo in trackInfoList) {if(tempInfo.trackIndex == 0) {//Switch to the required audio track by judging trackIndex or name_vodPlayerController.selectTrack(tempInfo.trackIndex);} else {// Unnecessary audio tracks are deselectTrack_vodPlayerController.deselectTrack(tempInfo.trackIndex);}}
setAutoPlay
in TXVodPlayerController
to implement the feature as follows:
// Play back video A: If `autoPlay` is set to `true`, the video will be immediately loaded and played back when `startVodPlay` is calledString urlA = "http://1252463788.vod2.myqcloud.com/xxxxx/v.f10.mp4";controller.setAutoPlay(isAutoPlay: true);controller.startVodPlay(urlA);// To preload video B when playing back video A, set `setAutoPlay` to `false`String urlB = "http://1252463788.vod2.myqcloud.com/xxxxx/v.f20.mp4";controller.setAutoPlay(isAutoPlay: false);controller.startVodPlay(urlB); // The video won't be played back immediately but will start to be loaded.
resume
function to immediately play back video B.autoPlay
is set to false
, make sure that video B has been prepared before calling resume
, that is, you should call it only after the PLAY_EVT_VOD_PLAY_PREPARED
event of video B (2013: the player has been prepared, and the video can be played back) is detected.controller.onPlayerEventBroadcast.listen((event) async {// Subscribe to status changeif(event["event"] == TXVodPlayEvent.PLAY_EVT_PLAY_END) {await _controller_A.stop();await _controller_B.resume();}});
AutoPlay
of the player is set to false
before video playback starts).TXVodPlayConfig config = new TXVodPlayConfig();config.setMaxPreloadSize(2); // Maximum preloading buffer size in MB. Set it based on your business conditions to reduce the traffic consumptionmVodPlayer.setConfig(config); // Pass in `config` to `mVodPlayer`
FTXVodPlayConfig config = FTXVodPlayConfig();config.maxBufferSize = 10; // The maximum buffer size during playback in MB_controller.setPlayConfig(config); // Pass in `config` to `controller`
TXPlayerGlobalSetting
is the global cache setting API, and the original TXVodConfig
API has been deprecated.TXVodConfig
of the player.// Set the global cache directory and cache size of the playback engineSuperPlayerPlugin.setGlobalMaxCacheSize(200);// The cache path is set to the application's sandbox directory by default. You only need to pass in the relative cache directory instead of the entire absolute path to `postfixPath`.// On Android, videos will be cached to the `Android/data/your-pkg-name/files/testCache` directory on the SD card.// On iOS, videos will be cached to the `Documents/testCache` directory in the sandbox.SuperPlayerPlugin.setGlobalCacheFolderPath("postfixPath");String palyrl = "http://****";// Start predownloadingint taskId = await TXVodDownloadController.instance.startPreLoad(palyrl, 3, 1920*1080,onCompleteListener:(int taskId,String url) {print('taskID=${taskId} ,url=${url}');}, onErrorListener: (int taskId, String url, int code, String msg) {print('taskID=${taskId} ,url=${url}, code=${code} , msg=${msg}');});// Cancel predownloadingTXVodDownloadController.instance.stopPreLoad(taskId);
// Set the global cache directory and cache size of the playback engineSuperPlayerPlugin.setGlobalMaxCacheSize(200);// The cache path is set to the application's sandbox directory by default. You only need to pass in the relative cache directory instead of the entire absolute path to `postfixPath`.// On Android, videos will be cached to the `Android/data/your-pkg-name/files/testCache` directory on the SD card.// On iOS, videos will be cached to the `Documents/testCache` directory in the sandbox.SuperPlayerPlugin.setGlobalCacheFolderPath("postfixPath");int retTaskId = -1;TXVodDownloadController.instance.startPreload(TXPlayInfoParams(appId: 0, fileId: "your fileId"), 1, 720 * 1080, onStartListener: (taskId, fileId, url, params) { // TXVodDownloadController will call this block for callback taskId and videoInforetTaskId = taskId; }, onCompleteListener: (taskId, url) { // preDownload complete }, onErrorListener: (taskId, url, code, msg) { // preDownload error });// Cancel predownloadingTXVodDownloadController.instance.stopPreLoad(retTaskId);
TXVodDownloadController
to implement offline HLS playback.TXVodDownloadController
can cache only non-nested HLS files but not MP4 and FLV files.TXVodDownloadController
is designed as a singleton; therefore, you cannot create multiple download objects. It is used as follows:// The cache path is set to the application's sandbox directory by default. You only need to pass in the relative cache directory instead of the entire absolute path to `postfixPath`.// On Android, videos will be cached to the `Android/data/your-pkg-name/files/testCache` directory on the SD card.// On iOS, videos will be cached to the `Documents/testCache` directory in the sandbox.SuperPlayerPlugin.setGlobalCacheFolderPath("postfixPath");
Fileid
, you need to pass in AppID
, Fileid
, and qualityId
at least. For signed videos, you also need to pass in pSign
. If no specific value is passed in to userName
, it will be default
by default.Fileid
and must enter the psign
parameter.// QUALITY_240P 240p// QUALITY_360P 360P// QUALITY_480P 480p// QUALITY_540P 540p// QUALITY_720P 720p// QUALITY_1080P 1080p// QUALITY_2K 2k// QUALITY_4K 4k// The quality parameter can be customized to take the minimum value of the resolution width and height// (for example, for a resolution of 1280*720, if you want to download a stream of this resolution,// you can pass in QUALITY_720P for the quality parameter). The player SDK will select a stream with// a resolution less than or equal to the passed-in resolution for downloading.// Using quality ID to downloadDownloadHelper.instance.startDownload(videoModel, qualityId);// Using mediaInfo to downloadDownloadHelper.instance.startDownloadOrg(mediaInfo);
userName
, it will be default
by default.TXVodDownloadMedialnfo medialnfo = TXVodDownloadMedialnfo();medialnfo.url = "http://1500005830.vod2.myqcloud.com/43843ec0vodtranscq1500005830/00eb06a88602268011437356984/video_10_0.m3u8";TXVodDownloadController.instance.startDonwload(medialnfo);
TXVodDownloadController.instance.setDownloadObserver((event, info) {}, (errorCode, errorMsg, info) {});
Event | Description |
EVENT_DOWNLOAD_START | The task started, that is, the SDK started the download. |
EVENT_DOWNLOAD_PROGRESS | The task progress. During download, the SDK will frequently call back this API. You can use mediaInfo.getProgress() to get the current progress. |
EVENT_DOWNLOAD_STOP | The task stopped. When you call stopDownload to stop the download, if this message is received, the download is stopped successfully. |
EVENT_DOWNLOAD_FINISH | Download was completed. If this callback is received, the entire file has been downloaded, and the downloaded file can be played back by TXVodPlayer . |
downlodOnErrorListener
method is called back, a download error occurred. If the network is disconnected during download, this API will be called back and the download task will stop.TXVodDownloadMedialnfo
object. You can access the URL or dataSource
to determine the download source and get other information such as download progress and file size.TXVodDownloadController.instance.stopDownload()
method to stop the download. The parameter is the TXVodDownloadMedialnfo
object passed in when download starts. The SDK supports checkpoint restart. If the download directory is not changed, when you resume downloading a file, the download will start from the point where it stopped.// Get the download lists of all users// You can distinguish between the download lists of different users by `userName` in the download informationList<TXVodDownloadMedialnfo> downloadInfoList = await TXVodDownloadController.instance.getDownloadList();
Fileid
, such as the current download status and progress, you need to pass in AppID
, Fileid
, and qualityId
.// Get the download information of a videoTXVodDownloadMedialnfo downloadInfo = await TXVodDownloadController.instance.getDownloadInfo(medialnfo);int? duration = downloadInfo.duration; // Get the total durationint? playableDuration = downloadInfo.playableDuration; // Get the playable duration of the downloaded videodouble? progress = downloadInfo.progress; // Get the download progressString? playPath = downloadInfo.playPath; // Get the offline playback path, which can be passed in to the player to start offline playback.int? downloadState = downloadInfo.downloadState; // Get the download status. For more information, see the `STATE_xxx` constant.
// Delete the download informationbool result = await TXVodDownloadController.instance.deleteDownloadMediaInfo(medialnfo);
appId
as well as the encrypted video's fileId
and psign
in the Tencent Cloud console, you can play back the video as follows:// `psign` is a player signature. For more information on the signature and how to generate it, see [Player Signature](https://www.tencentcloud.com/document/product/266/38099).TXPlayInfoParams params = TXPlayInfoParams(appId: 1252463788,fileId: "4564972819220421305", psign: "psignxxxxxxx");_controller.startVodPlayWithParams(params);
statPlay
, you can call setConfig
to configure the player parameters, such as player connection timeout period, progress callback interval, and maximum number of cached files. TXVodPlayConfig
allows you to configure detailed parameters. For more information, see Basic Configuration API. Below is the configuration sample code:FTXVodPlayConfig config = FTXVodPlayConfig();// If `preferredResolution` is not configured, the 720x1280 resolution stream will be played back preferably during multi-bitrate video playbackconfig.preferredResolution = 720 * 1280;config.enableAccurateSeek = true; // Set whether to enable accurate seek. Default value: `true`.config.progressInterval = 200; // Set the progress callback interval in millisecondsconfig.maxBufferSize = 50; // Set the maximum preloading buffer size in MB_controller.setPlayConfig(config);
setBitrateIndex
to switch to the required bitstream.FTXVodPlayConfig config = FTXVodPlayConfig();// The parameter passed in is the product of the video width and height. You can pass in a custom value. Default value: `720 * 1280`.config.preferredResolution = 720 * 1280;_controller.setPlayConfig(config);
TXVodPlayConfig#mediaType
to reduce the internal playback type detection of the player SDK.FTXVodPlayConfig config = FTXVodPlayConfig();config.mediaType = TXVodPlayEvent.MEDIA_TYPE_FILE_VOD; // Used to improve MP4 playback startup speedconfig.mediaType = TXVodPlayEvent.MEDIA_TYPE_HLS_VOD; // Used to improve HLS playback startup speed_controller.setPlayConfig(config);
FTXVodPlayConfig config = FTXVodPlayConfig();config.progressInterval = 200; // Set the progress callback interval in milliseconds_controller.setPlayConfig(config);
onPlayerEventBroadcast
of TXVodPlayerController
to sync information to your application.onPlayerEventBroadcast
)Event ID | Code | Description |
PLAY_EVT_PLAY_BEGIN | 2004 | Video playback started. |
PLAY_EVT_PLAY_PROGRESS | 2005 | The video playback progress (including the current playback progress, loading progress, and total video duration). |
PLAY_EVT_PLAY_LOADING | 2007 | The video is being loaded. The LOADING_END event will be reported if video playback resumes. |
PLAY_EVT_VOD_LOADING_END | 2014 | Video loading ended, and video playback resumed. |
VOD_PLAY_EVT_SEEK_COMPLETE | 2019 | Seeking was completed. The seeking feature is supported by v10.3 or later. |
Event ID | Code | Description |
PLAY_EVT_PLAY_END | 2006 | Video playback ended. |
PLAY_ERR_NET_DISCONNECT | -2301 | The network was disconnected and could not be reconnected after multiple retries. You can restart the player to perform more connection retries. |
PLAY_ERR_HLS_KEY | -2305 | Failed to get the HLS decryption key. |
Event ID | Code | Description |
PLAY_WARNING_VIDEO_DECODE_FAIL | 2101 | Failed to decode the current video frame. |
PLAY_WARNING_AUDIO_DECODE_FAIL | 2102 | Failed to decode the current audio frame. |
PLAY_WARNING_RECONNECT | 2103 | The network was disconnected, and automatic reconnection was performed (the PLAY_ERR_NET_DISCONNECT event will be thrown after three failed attempts). |
PLAY_WARNING_HW_ACCELERATION_FAIL | 2106 | Failed to start the hardware decoder, and the software decoder was used instead. |
Event ID | Code | Description |
PLAY_EVT_VOD_PLAY_PREPARED | 2013 | The player has been prepared and can start playback. If autoPlay is set to false , you need to call resume after receiving this event to start playback. |
PLAY_EVT_RCV_FIRST_I_FRAME | 2003 | The network received the first renderable video data packet (IDR). |
Event ID | Code | Description |
PLAY_EVT_CHANGE_RESOLUTION | 2009 | The video resolution changed. |
PLAY_EVT_CHANGE_ROTATION | 2011 | The MP4 video was rotated. |
Event ID | Code | Description |
PLAY_EVT_GET_PLAYINFO_SUCC | 2010 | Obtained the information of the file played back successfully. |
fileId
and the playback request succeeds (called API: startVodPlay(TXPlayerAuthBuilder authBuilder)
), the SDK will notify the upper layer of some request information, and you can parse param
to get the video information after receiving the TXLiveConstants.PLAY_EVT_GET_PLAYINFO_SUCC
event.Video Information | Description |
EVT_PLAY_COVER_URL | Video thumbnail URL |
EVT_PLAY_URL | Video playback address |
EVT_PLAY_DURATION | Video duration |
EVT_TIME | Event occurrence time |
EVT_UTC_TIME | UTC time |
EVT_DESCRIPTION | Event description |
EVT_PLAY_NAME | Video name |
EVT_IMAGESPRIT_WEBVTTURL | The download URL of the image sprite WebVTT file, which is supported by v10.2 or later. |
EVT_IMAGESPRIT_IMAGEURL_LIST | The download URL of the image sprite image, which is supported by v10.2 or later. |
EVT_DRM_TYPE | The encryption type, which is supported by v10.2 or later. |
onPlayerEventBroadcast
to get the video playback information:_controller.onPlayerEventBroadcast.listen((event) async {if (event["event"] == TXVodPlayEvent.PLAY_EVT_PLAY_BEGIN || event["event"] == TXVodPlayEvent.PLAY_EVT_RCV_FIRST_I_FRAME) {// code ...} else if (event["event"] == TXVodPlayEvent.PLAY_EVT_PLAY_PROGRESS) {// code ...}});
onPlayerNetStatusBroadcast
)Parameter | Description |
NET_STATUS_CPU_USAGE | Current instantaneous CPU utilization |
NET_STATUS_VIDEO_WIDTH | Video resolution - width |
NET_STATUS_VIDEO_HEIGHT | Video resolution - height |
NET_STATUS_NET_SPEED | Current network data reception speed |
NET_STATUS_VIDEO_FPS | Current video frame rate of streaming media |
NET_STATUS_VIDEO_BITRATE | Current video bitrate in Kbps of streaming media |
NET_STATUS_AUDIO_BITRATE | Current audio bitrate in Kbps of streaming media |
NET_STATUS_VIDEO_CACHE | Buffer (`jitterbuffer`) size. If the current buffer length is 0, lag will occur soon. |
NET_STATUS_SERVER_IP | Connected server IP |
onNetStatus
to get the video playback information:_controller.onPlayerNetStatusBroadcast.listen((event) async {int videoWidth = event[TXVodNetEvent.NET_STATUS_VIDEO_WIDTH];});
TXPlayerState
is used to transfer the event.Status | Description |
paused | The playback was paused |
failed | The playback failed |
buffering | Buffering |
playing | Playing back |
stopped | The playback was stopped |
disposed | The control was released |
onPlayerState
to get the video playback status:_controller.onPlayerState.listen((val) { });
SuperPlayerPlugin
to listen on the volume level change of the current device.onEventBroadcast
to get the volume level status of the device:SuperPlayerPlugin.instance.onEventBroadcast.listen((event) {int eventCode = event["event"];});
Status | Code | Description |
EVENT_VOLUME_CHANGED | 1 | The volume level changed. |
EVENT_AUDIO_FOCUS_PAUSE | 2 | The volume level output and playback focus were lost. This event is applicable only to Android. |
EVENT_AUDIO_FOCUS_PLAY | 3 | Obtained the volume level output focus successfully. This event is applicable only to Android. |
Status | Code | Description |
EVENT_PIP_MODE_ALREADY_ENTER | 1 | The player has entered the PiP mode. |
EVENT_PIP_MODE_ALREADY_EXIT | 2 | The player has exited the PiP mode. |
EVENT_PIP_MODE_REQUEST_START | 3 | The player requests to enter the PiP mode. |
EVENT_PIP_MODE_UI_STATE_CHANGED | 4 | The PiP UI status changed. This event takes effect only on Android 31 or later. |
EVENT_IOS_PIP_MODE_RESTORE_UI | 5 | The UI was reset. This event takes effect only on iOS. |
EVENT_IOS_PIP_MODE_WILL_EXIT | 6 | The player will exit the PiP mode. This event takes effect only on iOS. |
onExtraEventBroadcast
to listen on PiP events:SuperPlayerPlugin.instance.onExtraEventBroadcast.listen((event) {int eventCode = event["event"];});
この記事はお役に立ちましたか?