0
votes

I'd like to show a video (mp4) with the flutter package video_player. On iOS everything is working fine, but on android the file is not found. I can find the file in the apk at the right place, but the app is not finding it. Other asset files like images or pdfs are working.

_videoController = VideoPlayerController.asset("/assets/videos/$fileName");
    
com.google.android.exoplayer2.upstream.AssetDataSource$AssetDataSourceException: java.io.FileNotFoundException: flutter_assets//assets/videos/bcm.mp4
...
    Caused by: java.io.FileNotFoundException: flutter_assets//assets/videos/bcm.mp4
        at android.content.res.AssetManager.nativeOpenAsset(Native Method)
        ...

Am I missing something for android? Maybe in build.gradle? Thanks!

I also get this note, but I don't think that it is the problem:

Note: /.../development/flutter/.pub-cache/hosted/pub.dartlang.org/video_player-0.10.11+2/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java uses or overrides a deprecated API.

with -Xlint:deprecation:

/.../.pub-cache/hosted/pub.dartlang.org/video_player-0.10.11+2/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java:61: warning: [deprecation] getFlutterEngine() in FlutterPluginBinding has been deprecated
  binding.getFlutterEngine().getRenderer());
1
try this : delete (pubspec.lock , .packages , .flutter-plugins-dependencies , .flutter-plugins) files , then apply command "flutter pub get" , then apply command "flutter clean" , then "flutter run" .farouk osama
I then get a note "uses or overrides a deprecated API", see edited post. Thanks!Jan F.
But the problem remains, I don't think it is because of the deprecation.Jan F.

1 Answers

0
votes

Oops, it was because of the double slash in

 flutter_assets//assets/videos/...

In iOS it was also working, but on android only with one slash:

flutter_assets/assets/videos/...

So in the code no slash at the beginning of the asset method parameter:

_videoController = VideoPlayerController.asset("assets/videos/$fileName");