-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
244 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:bitmovin_player/bitmovin_player.dart'; | ||
import 'package:bitmovin_player/src/platform/cast_manager_platform_message_channel.dart'; | ||
import 'package:plugin_platform_interface/plugin_platform_interface.dart'; | ||
|
||
/// Platform interface for the cast manager. | ||
abstract class CastManagerPlatformInterface extends PlatformInterface | ||
implements BitmovinCastManagerApi { | ||
/// Constructs a [CastManagerPlatformInterface]. | ||
CastManagerPlatformInterface() : super(token: _token); | ||
|
||
static final Object _token = Object(); | ||
|
||
static CastManagerPlatformInterface _instance = | ||
CastManagerPlatformMessageChannel(); | ||
|
||
/// The instance of [CastManagerPlatformInterface] to use. | ||
/// | ||
/// Defaults to [CastManagerPlatformMessageChannel]. | ||
static CastManagerPlatformInterface get instance => _instance; | ||
|
||
/// Platform-specific implementations should set this with their own | ||
/// platform-specific class that extends [CastManagerPlatformInterface] | ||
/// when they register themselves. | ||
static set instance(CastManagerPlatformInterface instance) { | ||
PlatformInterface.verifyToken(instance, _token); | ||
_instance = instance; | ||
} | ||
|
||
/// Initializes the cast manager with the given [options]. | ||
Future<void> initializeCastManager(BitmovinCastManagerOptions options); | ||
} |
35 changes: 35 additions & 0 deletions
35
lib/src/platform/cast_manager_platform_message_channel.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:bitmovin_player/src/api/casting/bitmovin_cast_manager_options.dart'; | ||
import 'package:bitmovin_player/src/casting/custom_cast_message.dart'; | ||
import 'package:bitmovin_player/src/channel_manager.dart'; | ||
import 'package:bitmovin_player/src/channels.dart'; | ||
import 'package:bitmovin_player/src/methods.dart'; | ||
import 'package:bitmovin_player/src/platform/cast_manager_platform_interface.dart'; | ||
|
||
/// An implementation of [CastManagerPlatformInterface] that uses method | ||
/// channels. This is currently used for iOS and Android. | ||
class CastManagerPlatformMessageChannel extends CastManagerPlatformInterface { | ||
final _mainChannel = ChannelManager.registerMethodChannel( | ||
name: Channels.main, | ||
); | ||
|
||
@override | ||
Future<void> sendMessage({ | ||
required String message, | ||
String? messageNamespace, | ||
}) => | ||
_mainChannel.invokeMethod<void>( | ||
Methods.castManagerSendMessage, | ||
CustomCastMessage( | ||
message: message, | ||
messageNamespace: messageNamespace, | ||
).toJson(), | ||
); | ||
|
||
@override | ||
Future<void> initializeCastManager(BitmovinCastManagerOptions options) { | ||
return _mainChannel.invokeMethod<void>( | ||
Methods.castManagerInitialize, | ||
options.toJson(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:bitmovin_player/src/api/casting/bitmovin_cast_manager_options.dart'; | ||
import 'package:bitmovin_player/src/platform/cast_manager_platform_interface.dart'; | ||
|
||
/// An implementation of [CastManagerPlatformInterface] for the Web platform. | ||
class CastManagerPlatformWeb extends CastManagerPlatformInterface { | ||
BitmovinCastManagerOptions? _options; | ||
BitmovinCastManagerOptions? get options => _options; | ||
void Function(String)? castMessageHandler; | ||
|
||
@override | ||
Future<void> sendMessage({ | ||
required String message, | ||
String? messageNamespace, | ||
}) { | ||
castMessageHandler?.call(message); | ||
return Future.value(); | ||
} | ||
|
||
@override | ||
Future<void> initializeCastManager(BitmovinCastManagerOptions options) { | ||
_options = options; | ||
return Future.value(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.