I'm using flutter_inappwebview in a Flutter-app to display local html (from assets). (I know: not ideal. I would prefer to program the whole thing in Dart, but that is not an option right now). It works great..apart from one thing. Can't get the video in html to work.
Problem
The video works fine when I open the html in any browser (directly from assets folder). So the html should be ok. All other html works fine in the app. So files and pubspec-import should be ok. In the app, the page shows a video-player, but no content on both iOS-sim and iOS device. In the Android-sim it works.
Code
I'm using:
flutter_inappwebview: ^3.2.0
sdk: ">=2.7.0 <3.0.0"
I use the inappview like this, after the imports. Server is already running (flutter reports: flutter: Server running on http://localhost:8080)
InAppWebViewController webViewController;
InAppWebView webView;
class OfflineViewer extends StatefulWidget {
@override
_ViewerState createState() => _ViewerState();
}
class _ViewerState extends State<OfflineViewer> {
@override
Widget build(BuildContext context) {
return InAppWebView(
initialUrl: "http://localhost:8080/assets/source/intro.html",
onWebViewCreated: (InAppWebViewController controller) {
webViewController = controller;
},
);
}
}
The video-tag in the loaded intro.html is:
<video height="600" controls>
<source src="intro.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
Things I tried:
Different video-formats (webm, ogg) > no difference.
Loading an online video into the html instead of local > works. Video loads and plays.
Different methods of embedding video (video-tag, iframe, video.js) > no difference.
Setting InAppWebViewOptions, like:
cacheEnabled: true,
javaScriptCanOpenWindowsAutomatically: true,
useOnLoadResource: true,
javaScriptEnabled: true,
mediaPlaybackRequiresUserGesture: false,
What makes this hard to solve (for me) is that I can't catch the html-errors once it's embedded in the app, whereas the standalone html doesn't give an error. Any ideas on how to solve or even troubleshoot this are highly appreciated.
Greetings,
Mark