Video call at InAppWebView
parent
936b7c28f9
commit
23404b4495
@ -1,13 +0,0 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class VideoCallWebPage extends StatelessWidget{
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,108 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
|
|
||||||
|
class VideoCallWebPage extends StatelessWidget{
|
||||||
|
final GlobalKey webViewKey = GlobalKey();
|
||||||
|
|
||||||
|
InAppWebViewController webViewController;
|
||||||
|
InAppWebViewController controller;
|
||||||
|
|
||||||
|
URLRequest request;
|
||||||
|
final String receiverId;
|
||||||
|
final String callerId;
|
||||||
|
VideoCallWebPage({@required this.receiverId, @required this.callerId}){
|
||||||
|
request = URLRequest(url: Uri.parse("https://vcallapi.hmg.com/index.html?username=$receiverId"));
|
||||||
|
}
|
||||||
|
|
||||||
|
InAppWebViewGroupOptions options = InAppWebViewGroupOptions(
|
||||||
|
crossPlatform: InAppWebViewOptions(
|
||||||
|
cacheEnabled: false,
|
||||||
|
clearCache: true,
|
||||||
|
disableHorizontalScroll: true,
|
||||||
|
disableVerticalScroll: true,
|
||||||
|
disableContextMenu: true,
|
||||||
|
supportZoom: false,
|
||||||
|
javaScriptEnabled: true,
|
||||||
|
preferredContentMode: UserPreferredContentMode.MOBILE,
|
||||||
|
useShouldOverrideUrlLoading: true,
|
||||||
|
mediaPlaybackRequiresUserGesture: false,
|
||||||
|
|
||||||
|
),
|
||||||
|
android: AndroidInAppWebViewOptions(
|
||||||
|
hardwareAcceleration: true,
|
||||||
|
useHybridComposition: true,
|
||||||
|
),
|
||||||
|
ios: IOSInAppWebViewOptions(
|
||||||
|
allowsAirPlayForMediaPlayback: true,
|
||||||
|
allowsPictureInPictureMediaPlayback: true,
|
||||||
|
allowsInlineMediaPlayback: true,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
primary: true,
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Colors.transparent, leading: Container(),
|
||||||
|
systemOverlayStyle: SystemUiOverlayStyle(statusBarColor: Colors.black),
|
||||||
|
),
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
extendBody: false,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(height: MediaQuery.of(context).viewPadding.top),
|
||||||
|
Expanded(
|
||||||
|
child: InAppWebView(
|
||||||
|
androidOnPermissionRequest: androidOnPermissionRequest,
|
||||||
|
initialOptions: options,
|
||||||
|
initialUrlRequest: request,
|
||||||
|
onWebViewCreated: onWebViewCreated,
|
||||||
|
onLoadStart: onLoadStart,
|
||||||
|
onLoadError: onError,
|
||||||
|
onConsoleMessage: onConsoleMessage,
|
||||||
|
shouldOverrideUrlLoading: shouldRedirect ,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
ChromeSafariBrowser();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future<PermissionRequestResponse> androidOnPermissionRequest(InAppWebViewController controller, String origin, List<String> resources) async {
|
||||||
|
return PermissionRequestResponse(
|
||||||
|
resources: resources,
|
||||||
|
action: PermissionRequestResponseAction.GRANT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onWebViewCreated(InAppWebViewController controller) => this.controller = controller;
|
||||||
|
|
||||||
|
onConsoleMessage(controller, ConsoleMessage consoleMessage){
|
||||||
|
print(consoleMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
onError(InAppWebViewController controller, Uri url, int code, String message) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoadStart(InAppWebViewController controller, Uri url) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<NavigationActionPolicy> shouldRedirect(InAppWebViewController controller, NavigationAction navigationAction) async {
|
||||||
|
var uri = navigationAction.request.url;
|
||||||
|
if(uri.queryParameters['exit'] == "yes"){
|
||||||
|
Navigator.pop(webViewKey.currentContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NavigationActionPolicy.ALLOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue