Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http:// Video Source Cause Unhandled Exception on Android & Solution #80

Closed
thomastthai opened this issue Jan 28, 2023 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@thomastthai
Copy link

Using a video source from http:// instead of https:// will cause an Unhandled Exception on Android.

Let's take this video link as an example:

<video src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4">

E/flutter ( 2622): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error, null, null)
E/flutter ( 2622):
E/FlutterJNI( 2622): Failed to decode image
E/FlutterJNI( 2622): android.graphics.ImageDecoder$DecodeException: Failed to create image decoder with message 'unimplemented'Input contained an error.
E/FlutterJNI( 2622): 	at android.graphics.ImageDecoder.nCreate(Native Method)
E/FlutterJNI( 2622): 	at android.graphics.ImageDecoder.access$200(ImageDecoder.java:172)
E/FlutterJNI( 2622): 	at android.graphics.ImageDecoder$ByteBufferSource.createImageDecoder(ImageDecoder.java:242)
E/FlutterJNI( 2622): 	at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:2015)
E/FlutterJNI( 2622): 	at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:2008)
E/FlutterJNI( 2622): 	at io.flutter.embedding.engine.FlutterJNI.decodeImage(FlutterJNI.java:524)
E/FlutterJNI( 2622): Failed to decode image
E/FlutterJNI( 2622): android.graphics.ImageDecoder$DecodeException: Failed to create image decoder with message 'unimplemented'Input contained an error.
E/FlutterJNI( 2622): 	at android.graphics.ImageDecoder.nCreate(Native Method)
E/FlutterJNI( 2622): 	at android.graphics.ImageDecoder.access$200(ImageDecoder.java:172)
E/FlutterJNI( 2622): 	at android.graphics.ImageDecoder$ByteBufferSource.createImageDecoder(ImageDecoder.java:242)
E/FlutterJNI( 2622): 	at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:2015)
E/FlutterJNI( 2622): 	at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:2008)
E/FlutterJNI( 2622): 	at io.flutter.embedding.engine.FlutterJNI.decodeImage(FlutterJNI.java:524)

To use http:// video source, on iOS and Android, the following changes, as described in the video_player package, may help:

iOS
If you need to access videos using http (rather than https) URLs, you will need to add the appropriate NSAppTransportSecurity permissions to your app's Info.plist file, located in <project root>/ios/Runner/Info.plist. See Apple's documentation to determine the right combination of entries for your use case and supported iOS versions.

Android
If you are using network-based videos, ensure that the following permission is present in your Android Manifest file, located in <project root>/android/app/src/main/AndroidManifest.xml:

On Android, add the following in AndroidManifest.xml:

<application ...
android:usesCleartextTraffic="true"
...

Clean up, update, and re-run

$ flutter clean && flutter pub get && flutter run --debug

No more errors while accessing the video file from http://.

@thomastthai thomastthai added the bug Something isn't working label Jan 28, 2023
@asjqkkkk
Copy link
Owner

asjqkkkk commented Feb 3, 2023

Hi @thomastthai thanks for your issue and solution
You can also submit a pull request or I'll fix them in the next version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants