diff --git a/lib/src/controller.dart b/lib/src/controller.dart index acffc6e..c5d90a2 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -6,6 +6,9 @@ import 'dart:typed_data'; import 'package:video_player/video_player.dart'; import 'package:video_player_platform_interface/video_player_platform_interface.dart'; +import 'media_info.dart' + if (dart.library.js_interop) 'media_info_dummy.dart' + if (dart.library.html) 'media_info_dummy.dart'; import 'video_player_mdk.dart' if (dart.library.js_interop) 'video_player_dummy.dart' if (dart.library.html) 'video_player_dummy.dart'; @@ -28,6 +31,11 @@ extension FVPControllerExtensions on VideoPlayerController { return _platform.isLive(textureId); } + /// Get current media info. + MediaInfo? getMediaInfo() { + return _platform.getMediaInfo(textureId); + } + /// set additional properties /// https://github.com/wang-bin/mdk-sdk/wiki/Player-APIs#void-setpropertyconst-stdstring-key-const-stdstring-value void setProperty(String name, String value) { @@ -118,6 +126,11 @@ extension FVPControllerExtensions on VideoPlayerController { _platform.setAudioTracks(textureId, value); } + /// Get active audio tracks. + List? getActiveAudioTracks() { + return _platform.getActiveAudioTracks(textureId); + } + /// Set active video tracks. Other tracks will be disabled. /// The tracks can be from data source from [VideoPlayerController] constructor, or an external video data source via [setExternalVideo] /// https://github.com/wang-bin/mdk-sdk/wiki/Player-APIs#void-setactivetracksmediatype-type-const-stdsetint-tracks @@ -125,6 +138,11 @@ extension FVPControllerExtensions on VideoPlayerController { _platform.setVideoTracks(textureId, value); } + /// Get active video tracks. + List? getActiveVideoTracks() { + return _platform.getActiveVideoTracks(textureId); + } + /// Set active subtitle tracks. Other tracks will be disabled. /// The tracks can be from data source from [VideoPlayerController] constructor, or an external subtitle data source via [setExternalSubtitle] /// https://github.com/wang-bin/mdk-sdk/wiki/Player-APIs#void-setactivetracksmediatype-type-const-stdsetint-tracks @@ -132,6 +150,11 @@ extension FVPControllerExtensions on VideoPlayerController { _platform.setSubtitleTracks(textureId, value); } + /// Get active subtitle tracks. + List? getActiveSubtitleTracks() { + return _platform.getActiveSubtitleTracks(textureId); + } + /// set an external audio data source /// https://github.com/wang-bin/mdk-sdk/wiki/Player-APIs#void-setmediaconst-char-url-mediatype-type void setExternalAudio(String uri) { diff --git a/lib/src/media_info_dummy.dart b/lib/src/media_info_dummy.dart new file mode 100644 index 0000000..6bd3bf1 --- /dev/null +++ b/lib/src/media_info_dummy.dart @@ -0,0 +1,4 @@ +/// A dummy class for web +class MediaInfo { + +} \ No newline at end of file diff --git a/lib/src/video_player_dummy.dart b/lib/src/video_player_dummy.dart index e571d30..3e40405 100644 --- a/lib/src/video_player_dummy.dart +++ b/lib/src/video_player_dummy.dart @@ -1,5 +1,7 @@ import 'dart:typed_data'; +import 'media_info_dummy.dart'; + /// A dummy class for web class MdkVideoPlayerPlatform { static void registerVideoPlayerPlatformsWith({dynamic options}) {} @@ -9,6 +11,8 @@ class MdkVideoPlayerPlatform { return false; } + MediaInfo? getMediaInfo(int textureId) { return null; } + void setProperty(int textureId, String name, String value) {} void setAudioDecoders(int textureId, List value) {} @@ -37,12 +41,25 @@ class MdkVideoPlayerPlatform { void setHue(int textureId, double value) {} void setSaturation(int textureId, double value) {} + void setAudioTracks(int textureId, List value) {} + List? getActiveAudioTracks(int textureId) { + return null; + } + void setVideoTracks(int textureId, List value) {} + List? getActiveVideoTracks(int textureId) { + return null; + } + void setSubtitleTracks(int textureId, List value) {} + List? getActiveSubtitleTracks(int textureId) { + return null; + } + void setExternalAudio(int textureId, String uri) {} void setExternalVideo(int textureId, String uri) {} diff --git a/lib/src/video_player_mdk.dart b/lib/src/video_player_mdk.dart index b7258b1..3aae396 100644 --- a/lib/src/video_player_mdk.dart +++ b/lib/src/video_player_mdk.dart @@ -10,9 +10,11 @@ import 'package:video_player_platform_interface/video_player_platform_interface. import 'package:logging/logging.dart'; import 'fvp_platform_interface.dart'; import 'extensions.dart'; +import 'media_info.dart'; import '../mdk.dart' as mdk; + final _log = Logger('fvp'); class MdkVideoPlayer extends mdk.Player { @@ -349,9 +351,10 @@ class MdkVideoPlayerPlatform extends VideoPlayerPlatform { return _players[textureId]?.isLive ?? false; } - //MediaInfo getMediaInfo() { - // - //} + MediaInfo? getMediaInfo(int textureId) { + return _players[textureId]?.mediaInfo; + } + void setProperty(int textureId, String name, String value) { _players[textureId]?.setProperty(name, value); } @@ -422,14 +425,26 @@ class MdkVideoPlayerPlatform extends VideoPlayerPlatform { _players[textureId]?.activeAudioTracks = value; } + List? getActiveAudioTracks(int textureId) { + return _players[textureId]?.activeAudioTracks; + } + void setVideoTracks(int textureId, List value) { _players[textureId]?.activeVideoTracks = value; } + List? getActiveVideoTracks(int textureId) { + return _players[textureId]?.activeVideoTracks; + } + void setSubtitleTracks(int textureId, List value) { _players[textureId]?.activeSubtitleTracks = value; } + List? getActiveSubtitleTracks(int textureId) { + return _players[textureId]?.activeSubtitleTracks; + } + // external track. can select external tracks via setAudioTracks() void setExternalAudio(int textureId, String uri) { _players[textureId]?.setMedia(uri, mdk.MediaType.audio);