AdBreakProgress flutter
This commit is contained in:
parent
cc735e6adb
commit
9269a67c4a
3 changed files with 35 additions and 0 deletions
|
|
@ -5,6 +5,13 @@ import '../../cast.dart';
|
|||
import '../PlatformBridgeApis.dart';
|
||||
|
||||
typedef ProgressListener = void Function(int progressMs, int durationMs);
|
||||
typedef AdBreakClipProgressListener = void Function(
|
||||
String adBreakId,
|
||||
String adBreakClipId,
|
||||
int progressMs,
|
||||
int durationMs,
|
||||
int whenSkippableMs,
|
||||
);
|
||||
|
||||
/// Class for controlling a media player application running on a receiver.
|
||||
class RemoteMediaClient {
|
||||
|
|
@ -38,6 +45,9 @@ class RemoteMediaClient {
|
|||
/// Called when receiving media error message.
|
||||
VoidCallback? onMediaError;
|
||||
|
||||
/// Callback to get updates on the progess of the currently playing ad break clip
|
||||
AdBreakClipProgressListener? onAdBreakClipProgressUpdated;
|
||||
|
||||
/// Loads a new media item with specified options.
|
||||
void load(MediaLoadRequestData request) {
|
||||
_hostApi.loadMediaLoadRequestData(request);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ class _ExpandedControlsState extends State<ExpandedControls> {
|
|||
sessionManager.remoteMediaClient.playerState
|
||||
.addListener(_onPlayerStateChanged);
|
||||
sessionManager.remoteMediaClient.onProgressUpdated = _onProgressUpdated;
|
||||
sessionManager.remoteMediaClient.onAdBreakClipProgressUpdated =
|
||||
_onAdBreakClipProgressUpdated;
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
|
@ -67,6 +69,7 @@ class _ExpandedControlsState extends State<ExpandedControls> {
|
|||
sessionManager.remoteMediaClient.playerState
|
||||
.removeListener(_onPlayerStateChanged);
|
||||
sessionManager.remoteMediaClient.onProgressUpdated = null;
|
||||
sessionManager.remoteMediaClient.onAdBreakClipProgressUpdated = null;
|
||||
|
||||
widget.controller.dispose();
|
||||
|
||||
|
|
@ -104,6 +107,16 @@ class _ExpandedControlsState extends State<ExpandedControls> {
|
|||
widget.controller.updateProgress(progress, duration);
|
||||
}
|
||||
|
||||
void _onAdBreakClipProgressUpdated(
|
||||
String adBreakId,
|
||||
String adBreakClipId,
|
||||
int progressMs,
|
||||
int durationMs,
|
||||
int whenSkippableMs,
|
||||
) {
|
||||
widget.controller.updateProgress(progressMs, durationMs);
|
||||
}
|
||||
|
||||
Widget _getDecoratedToolbar(MediaInfo? mediaInfo) {
|
||||
// Title and subtitle can't be retrieved at the moment
|
||||
// final title = mediaInfo?.mediaMetadata?.strings[MediaMetadataKey.title]
|
||||
|
|
|
|||
|
|
@ -149,5 +149,17 @@ class _CastFlutterApiImplementor extends CastFlutterApi {
|
|||
void onProgressUpdated(int progressMs, int durationMs) {
|
||||
remoteMediaClient.onProgressUpdated?.call(progressMs, durationMs);
|
||||
}
|
||||
|
||||
@override
|
||||
void onAdBreakClipProgressUpdated(String adBreakId, String adBreakClipId,
|
||||
int progressMs, int durationMs, int whenSkippableMs) {
|
||||
remoteMediaClient.onAdBreakClipProgressUpdated?.call(
|
||||
adBreakId,
|
||||
adBreakClipId,
|
||||
progressMs,
|
||||
durationMs,
|
||||
whenSkippableMs,
|
||||
);
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue