RemoteMediaClient setMute pigeon, android, ios
This commit is contained in:
parent
d31ff882b5
commit
d82e78be12
7 changed files with 87 additions and 1 deletions
|
|
@ -356,6 +356,7 @@ public class PlatformBridgeApis {
|
|||
public interface CastHostApi {
|
||||
void sendMessage(CastMessage message);
|
||||
void showCastDialog();
|
||||
void setMute(Boolean muted);
|
||||
void loadMediaLoadRequestData(MediaLoadRequestData request);
|
||||
MediaInfo getMediaInfo();
|
||||
void play();
|
||||
|
|
@ -412,6 +413,30 @@ public class PlatformBridgeApis {
|
|||
channel.setMessageHandler(null);
|
||||
}
|
||||
}
|
||||
{
|
||||
BasicMessageChannel<Object> channel =
|
||||
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CastHostApi.setMute", getCodec());
|
||||
if (api != null) {
|
||||
channel.setMessageHandler((message, reply) -> {
|
||||
Map<String, Object> wrapped = new HashMap<>();
|
||||
try {
|
||||
ArrayList<Object> args = (ArrayList<Object>)message;
|
||||
Boolean mutedArg = (Boolean)args.get(0);
|
||||
if (mutedArg == null) {
|
||||
throw new NullPointerException("mutedArg unexpectedly null.");
|
||||
}
|
||||
api.setMute(mutedArg);
|
||||
wrapped.put("result", null);
|
||||
}
|
||||
catch (Error | RuntimeException exception) {
|
||||
wrapped.put("error", wrapError(exception));
|
||||
}
|
||||
reply.reply(wrapped);
|
||||
});
|
||||
} else {
|
||||
channel.setMessageHandler(null);
|
||||
}
|
||||
}
|
||||
{
|
||||
BasicMessageChannel<Object> channel =
|
||||
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CastHostApi.loadMediaLoadRequestData", getCodec());
|
||||
|
|
|
|||
|
|
@ -219,7 +219,6 @@ class FlutterCastFrameworkPlugin : FlutterPlugin, MethodCallHandler, ActivityAwa
|
|||
}
|
||||
|
||||
override fun onProgressUpdated(progressMs: Long, durationMs: Long) {
|
||||
Log.d(TAG, "RemoteMediaClient - onProgressUpdated progress: $progressMs duration: $durationMs")
|
||||
flutterApi?.onProgressUpdated(progressMs, durationMs) { }
|
||||
}
|
||||
}
|
||||
|
|
@ -272,6 +271,12 @@ class FlutterCastFrameworkPlugin : FlutterPlugin, MethodCallHandler, ActivityAwa
|
|||
val remoteMediaClient: RemoteMediaClient = remoteMediaClient ?: return
|
||||
remoteMediaClient.stop()
|
||||
}
|
||||
|
||||
override fun setMute(muted: Boolean?) {
|
||||
if (muted == null) return
|
||||
val castSession = mCastSession ?: return
|
||||
castSession.isMute = muted
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOnNamespaceResult(oldSession: CastSession?, newSession: CastSession?) = PlatformBridgeApis.CastFlutterApi.Reply<MutableList<String>> { namespaces ->
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ NSObject<FlutterMessageCodec> *CastHostApiGetCodec(void);
|
|||
@protocol CastHostApi
|
||||
- (void)sendMessageMessage:(CastMessage *)message error:(FlutterError *_Nullable *_Nonnull)error;
|
||||
- (void)showCastDialogWithError:(FlutterError *_Nullable *_Nonnull)error;
|
||||
- (void)setMuteMuted:(NSNumber *)muted error:(FlutterError *_Nullable *_Nonnull)error;
|
||||
- (void)loadMediaLoadRequestDataRequest:(MediaLoadRequestData *)request error:(FlutterError *_Nullable *_Nonnull)error;
|
||||
- (nullable MediaInfo *)getMediaInfoWithError:(FlutterError *_Nullable *_Nonnull)error;
|
||||
- (void)playWithError:(FlutterError *_Nullable *_Nonnull)error;
|
||||
|
|
|
|||
|
|
@ -306,6 +306,26 @@ void CastHostApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<CastH
|
|||
[channel setMessageHandler:nil];
|
||||
}
|
||||
}
|
||||
{
|
||||
FlutterBasicMessageChannel *channel =
|
||||
[FlutterBasicMessageChannel
|
||||
messageChannelWithName:@"dev.flutter.pigeon.CastHostApi.setMute"
|
||||
binaryMessenger:binaryMessenger
|
||||
codec:CastHostApiGetCodec()];
|
||||
if (api) {
|
||||
NSCAssert([api respondsToSelector:@selector(setMuteMuted:error:)], @"CastHostApi api (%@) doesn't respond to @selector(setMuteMuted:error:)", api);
|
||||
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
|
||||
NSArray *args = message;
|
||||
NSNumber *arg_muted = args[0];
|
||||
FlutterError *error;
|
||||
[api setMuteMuted:arg_muted error:&error];
|
||||
callback(wrapResult(nil, error));
|
||||
}];
|
||||
}
|
||||
else {
|
||||
[channel setMessageHandler:nil];
|
||||
}
|
||||
}
|
||||
{
|
||||
FlutterBasicMessageChannel *channel =
|
||||
[FlutterBasicMessageChannel
|
||||
|
|
|
|||
|
|
@ -215,6 +215,14 @@ public class SwiftFlutterCastFrameworkPlugin: NSObject, FlutterPlugin, GCKSessio
|
|||
remoteMediaClient?.stop()
|
||||
}
|
||||
|
||||
public func setMuteMuted(_ muted: NSNumber, error: AutoreleasingUnsafeMutablePointer<FlutterError?>) {
|
||||
if (castSession == nil) {
|
||||
return
|
||||
}
|
||||
let isMuted = muted == 1
|
||||
castSession?.setDeviceMuted(isMuted)
|
||||
}
|
||||
|
||||
// MARK: - GCKSessionManagerListener
|
||||
|
||||
// onSessionSuspended
|
||||
|
|
|
|||
|
|
@ -311,6 +311,29 @@ class CastHostApi {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> setMute(bool arg_muted) async {
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.CastHostApi.setMute', codec, binaryMessenger: _binaryMessenger);
|
||||
final Map<Object?, Object?>? replyMap =
|
||||
await channel.send(<Object>[arg_muted]) as Map<Object?, Object?>?;
|
||||
if (replyMap == null) {
|
||||
throw PlatformException(
|
||||
code: 'channel-error',
|
||||
message: 'Unable to establish connection on channel.',
|
||||
details: null,
|
||||
);
|
||||
} else if (replyMap['error'] != null) {
|
||||
final Map<Object?, Object?> error = (replyMap['error'] as Map<Object?, Object?>?)!;
|
||||
throw PlatformException(
|
||||
code: (error['code'] as String?)!,
|
||||
message: error['message'] as String?,
|
||||
details: error['details'],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadMediaLoadRequestData(MediaLoadRequestData arg_request) async {
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.CastHostApi.loadMediaLoadRequestData', codec, binaryMessenger: _binaryMessenger);
|
||||
|
|
|
|||
|
|
@ -221,11 +221,15 @@ class CastMessage {
|
|||
abstract class CastHostApi {
|
||||
void sendMessage(CastMessage message);
|
||||
void showCastDialog();
|
||||
void setMute(bool muted);
|
||||
|
||||
//region RemoteMediaClient
|
||||
void loadMediaLoadRequestData(MediaLoadRequestData request);
|
||||
MediaInfo getMediaInfo();
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
//endregion
|
||||
}
|
||||
|
||||
@FlutterApi()
|
||||
|
|
|
|||
Loading…
Reference in a new issue