error VideoPlayer on Android

I can’t play video on android.
unity 2018.4.1f1
android 10 (pixel3)

void Play()
{
    videoPlayer.source = VideoSource.Url;
    var filePath = string.Format("file://{0}/0.mp4", Application.temporaryCachePath);
    videoPlayer.url = filePath;
    Debug.LogFormat("[VideoManager] [Play] filepath:`{0}`", filePath);

    videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
    videoPlayer.EnableAudioTrack(0, true);
    videoPlayer.SetTargetAudioSource(0, AudioManager.Instance.VideoAudioSource);

    videoPlayer.prepareCompleted += PrepareCompleted;
    videoPlayer.errorReceived += ErrorReceived;

    videoPlayer.enabled = true;
    videoPlayer.Prepare();
}

void PrepareCompleted(VideoPlayer vp)
{
    vp.prepareCompleted -= PrepareCompleted;
    vp.errorReceived -= ErrorReceived;
    vp.Play();
}

void ErrorReceived(VideoPlayer vp, string message)
{
    vp.prepareCompleted -= PrepareCompleted;
    vp.errorReceived -= ErrorReceived;
}

adb logcat

09-10 07:54:05.423  1701  1785 I Unity   : [VideoManager] [Play] filepath:`file:///storage/emulated/0/Android/data/com.xxxx.xxxx/cache/0.mp4`
09-10 07:54:05.423  1701  1785 I Unity   : VideoManager:Play(Int32, Single, Boolean)
09-10 07:54:05.423  1701  1785 I Unity   :
09-10 07:54:05.423  1701  1785 I Unity   : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
09-10 07:54:05.423  1701  1785 I Unity   :
09-10 07:54:05.449  1701  1823 E NdkMediaExtractor: can't create http service
09-10 07:54:05.449  1701  1823 W Unity   : AndroidVideoMedia: Error opening extractor: -10002
09-10 07:54:05.449  1701  1823 W Unity   :
09-10 07:54:05.449  1701  1823 W Unity   : (Filename:  Line: 471)
09-10 07:54:05.449  1701  1823 W Unity   :

Confirmed that the file exists
I don’t know the error code(-10002)

2 Likes

me too

AndroidVideoMedia: Error opening extractor: -10002

Unity 2018.1.9f2
Android10 Pixel3a

1 Like

I have the same error on my Pixel 3, Android 10.

Hello! If you can still reproduce the issue on latest releases of Unity, could you please submit a bug report with a minimal reproduction project for this issue and reply in here with the issue ID?

I have the same issue on android 10. The project worked fine on android 9, upgraded to 10 and now I get:

W/Unity: AndroidVideoMedia: Error opening extractor: -10002```

The video file is stored locally:

```VP = this.GetComponent<VideoPlayer>();
Internal_Storage_FileName = Path.Combine(Application.persistentDataPath, Video_Name + ".mp4");
VP.url = Internal_Storage_FileName;

Pixel 3, Android 10
Unity 2019.2.0f1

I have the same issue on android 10 (Pixel 3a, Built by Unity 2018.3.12f1)
Playing movie by streaming works well.
Handheld.PlayFullScreenMovie works well too.

Playing movie by VideoPlayer on local storage (temporaryCachePath and persistentDataPath) doesn’t work.

videoPlayer.errorReceived
reports

VideoPlayer cannot play url : file:///....
Cannot read file.
1 Like

Exact same issue here, Unity 2017.4.29f1 (LTS). It is working perfectly fine iOS and Android except Android 10. The video file is accessible at the expected url and I can play it manually.

Relevant logs:

10-07 11:19:24.621 14231 14302 E NdkMediaExtractor: can’t create http service
10-07 11:19:24.621 14231 14302 W Unity : AndroidVideoMedia: Error opening extractor: -10002
10-07 11:19:24.621 14231 14302 W Unity :
10-07 11:19:24.621 14231 14302 W Unity : (Filename: Line: 524)
10-07 11:19:24.621 14231 14302 W Unity :

10-07 11:19:24.672 14231 14274 E Unity : MediaView :: VideoPlayerOnErrorReceived ERROR : VideoPlayer cannot play url : /storage/emulated/0/Android/data/com.privatebundle.id/files/0xfLAYfU.mp4
10-07 11:19:24.672 14231 14274 E Unity : UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[ ])
10-07 11:19:24.672 14231 14274 E Unity : UnityEngine.Logger:Log(LogType, Object)
10-07 11:19:24.672 14231 14274 E Unity :
10-07 11:19:24.672 14231 14274 E Unity : (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/Android/runtime/DebugBindings.gen.cpp Line: 51)

edit: I reproduced the issue in a very small project. The key is simply to put a valid .mp4 file into Application.persistentDataPath + “/myvideo.mp4”. I pasted my file directly in that folder. It works perfectly fine on my galaxy s8+ (android 9.0). Then I tried on Pixel 2 (android 10.0) and I have the exact error above.

edit 2: I had an idea. At runtime, I load the video file using WWW request.

  • 10-07 15:58:03.143 10661 10683 I Unity : www loaded, , count = 269520

The byte[ ] length is correct. Then, I do the following:
string destinationPath = System.IO.Path.Combine(Application.temporaryCachePath, “temp.mp4”);
File.WriteAllBytes(destinationPath, www.bytes);:wink:

Then I pass the temporaryCachePath URL to the video player. Exact same issue…

10-07 15:58:03.161 10661 10751 E NdkMediaExtractor: can’t create http service
10-07 15:58:03.162 10661 10751 W Unity : AndroidVideoMedia: Error opening extractor: -10002
10-07 15:58:03.175 10661 10683 E Unity : VideoOnErrorReceived ERROR: VideoPlayer cannot play url : /storage/emulated/0/Android/data/com.mycompany.videoplayerandroidpie/cache/temp.mp4

@Domas_L :slight_smile:

3 Likes

webm(vp8)も同じ問題が発生しました。
android10でfile:///でアクセス出来なくなっているのが問題だと思います。回避するmanifestが見当たらないので、なんとかしてほしいものです。
2018.4.1f1~ 2018.4.10f1のすべてで解決されていないのを確認しています。

The same problem occurred in webm (vp8).
I think that the problem is that you can not access at file: /// on android10. I don’t see any manifests to avoid, so I’d like somehow.
It has been confirmed that it has not been resolved in all of 2018.4.1f1 to 2018.4.10f1.

1 Like

I suspect that it might be related with the new android 10 storage permission: The Death of External Storage: The End of the Saga(?)

1 Like

Bug reported, id 1189995
Thank you!

1 Like

I got the same issue and I tried to use runtime permission request for

"android.permission.READ_EXTERNAL_STORAGE"

But the app crashes. If I finally fix this request, will it help at all or we need to wait until VideoPlayer bug fixed?

I’m experiencing the same issue. Also trying to pass a cached video url to the VideoPlay on a device running Android 10. I know Unity has said this is working per design, but the suggested modification to the Android Manifest has not resolved the issue…

1 Like

Also experiencing the same issue. Video is not playing on Android Q / Pixel 2 when using a local filesystem url. Remote URLs are working just fine. Permissions are correctly set, and videos are playing on any other device/OS.

W/Unity: AndroidVideoMedia: Error opening extractor: -10002.

I also tried to target API 29 and set the new attribute: android:requestLegacyExternalStorage=“true”, but it didn’t help.

2 Likes

Just for experiment fixed permissions, set properly but video still can’t be player with a same error message. So the only way is to await for bug fix.

Man, I can’t find this bug by provided id. Are you sure it’s commited?

The case is still being processed by the CQA, you will be able to see the bug on the IssueTracker only after it gets processed.

After digging into the issue more and reading some Android logcats, I’m guessing the issue won’t be resolved by setting a certain permission (I’ve tried a bunch) but is related to the privacy and scoped storage changes Android made in 10/Q. I did a quick test, made a native android plugin using the getExternalFilesDir() command and passing the resulting path the Unity VideoPlayer, but that still results in a -10002 error and the video not playing. I think the issue has to do with how the VideoPlayer uses the URL to retrieve the video from the device. Read more about the Android Q changes here: https://developer.android.com/about/versions/10/privacy/changes

I would love to hear from someone at Unity regarding this…

Also experiencing the same issue. Video is not playing on Android 10 Pixel 1 when using a local filesystem url. I tried modifying manifest per Unity Issue Tracker - [Android] Video is not being rendered when using URL on some Android devices
but i still get the same error. Is this being worked on?

1 Like

Hi again!
The submitted case (1189995) has been resolved as a duplicate of another issue, which is already fixed in 2019.2.11f1, 2019.3.0b8, 2020.1.0a9 and above. Currently, the fix is also planned for 2017.4 and 2018.4 streams. You can find more information here:

3 Likes

Awesome! Thank you for the update! When can we get a download for Unity 2019.2.11f1? The latest I’m seeing in the Hub and download archive is 2019.2.10.

1 Like