diff --git a/lib/pages/webRTC/OpenTok/OpenTok.dart b/lib/pages/webRTC/OpenTok/OpenTok.dart index cf46ea15..1b2c87df 100644 --- a/lib/pages/webRTC/OpenTok/OpenTok.dart +++ b/lib/pages/webRTC/OpenTok/OpenTok.dart @@ -107,13 +107,13 @@ class OpenTokState extends State { List platformVideoViews() { return [ - SizedBox(width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, child: remoteVideoOnFull ? remotePlatformVideoView() : localPlatformVideoView()), + SizedBox(width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, child: remoteVideoOnFull ? returnFlutterNewRemoteWidget() : returnFlutterNewLocalWidget()), DraggablePublisher( onButtonBarHeight: ((double) async* {}(50)), onButtonBarVisible: ((bool) async* {}(true)), availableScreenSize: MediaQuery.of(context).size, child: InkWell( - child: (remoteVideoOnFull ? localPlatformVideoView() : remotePlatformVideoView()), + child: (remoteVideoOnFull ? returnFlutterNewLocalWidget() : returnFlutterNewRemoteWidget()), onTap: () { print(''); }, @@ -122,57 +122,87 @@ class OpenTokState extends State { ]; } - Widget localPlatformVideoView() { - return PlatformViewLink( - viewType: 'local-video-container', // custom platform-view-type - surfaceFactory: (BuildContext context, PlatformViewController controller) { - return AndroidViewSurface( - controller: controller, - gestureRecognizers: const >{}, - hitTestBehavior: PlatformViewHitTestBehavior.opaque, - ); - }, - - onCreatePlatformView: (PlatformViewCreationParams params) { - return PlatformViewsService.initSurfaceAndroidView( - id: params.id, - viewType: 'local-video-container', - // custom platform-view-type, - layoutDirection: TextDirection.ltr, - creationParams: {}, - creationParamsCodec: StandardMessageCodec(), - ) - ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated) - ..create(); - }, - ); + // Widget localPlatformVideoView() { + // return PlatformViewLink( + // viewType: 'local-video-container', // custom platform-view-type + // surfaceFactory: (BuildContext context, PlatformViewController controller) { + // return AndroidViewSurface( + // controller: controller, + // gestureRecognizers: const >{}, + // hitTestBehavior: PlatformViewHitTestBehavior.opaque, + // ); + // }, + // + // onCreatePlatformView: (PlatformViewCreationParams params) { + // return PlatformViewsService.initSurfaceAndroidView( + // id: params.id, + // viewType: 'local-video-container', + // // custom platform-view-type, + // layoutDirection: TextDirection.ltr, + // creationParams: {}, + // creationParamsCodec: StandardMessageCodec(), + // ) + // ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated) + // ..create(); + // }, + // ); + // } + + Widget returnFlutterNewRemoteWidget() { + final Map args = {"someInit": "initData"}; + const StandardMessageCodec _decoder = StandardMessageCodec(); + if (defaultTargetPlatform == TargetPlatform.android) { + return AndroidView( + viewType: 'remote-video-container', + creationParams: args, + creationParamsCodec: _decoder); + } + return UiKitView( + viewType: 'remote-video-container', + creationParams: args, + creationParamsCodec: _decoder); } - Widget remotePlatformVideoView() { - return PlatformViewLink( - viewType: 'remote-video-container', // custom platform-view-type - surfaceFactory: (BuildContext context, PlatformViewController controller) { - return AndroidViewSurface( - controller: controller, - gestureRecognizers: const >{}, - hitTestBehavior: PlatformViewHitTestBehavior.opaque, - ); - }, - onCreatePlatformView: (PlatformViewCreationParams params) { - return PlatformViewsService.initSurfaceAndroidView( - id: params.id, - viewType: 'remote-video-container', - // custom platform-view-type, - layoutDirection: TextDirection.ltr, - creationParams: {}, - creationParamsCodec: StandardMessageCodec(), - ) - ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated) - ..create(); - }, - ); + Widget returnFlutterNewLocalWidget() { + final Map args = {"someInit": "initData"}; + const StandardMessageCodec _decoder = StandardMessageCodec(); + if (defaultTargetPlatform == TargetPlatform.android) { + return AndroidView( + viewType: 'local-video-container', + creationParams: args, + creationParamsCodec: _decoder); + } + return UiKitView( + viewType: 'local-video-container', + creationParams: args, + creationParamsCodec: _decoder); } + // Widget remotePlatformVideoView() { + // return PlatformViewLink( + // viewType: 'remote-video-container', // custom platform-view-type + // surfaceFactory: (BuildContext context, PlatformViewController controller) { + // return AndroidViewSurface( + // controller: controller, + // gestureRecognizers: const >{}, + // hitTestBehavior: PlatformViewHitTestBehavior.opaque, + // ); + // }, + // onCreatePlatformView: (PlatformViewCreationParams params) { + // return PlatformViewsService.initSurfaceAndroidView( + // id: params.id, + // viewType: 'remote-video-container', + // // custom platform-view-type, + // layoutDirection: TextDirection.ltr, + // creationParams: {}, + // creationParamsCodec: StandardMessageCodec(), + // ) + // ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated) + // ..create(); + // }, + // ); + // } + _onAudioEnable() async { await openTokPlatform.toggleAudio(); _audioButton.add(!audioMute);