Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Video error VideoPlayer on Android

Discussion in 'Audio & Video' started by charcreon, Sep 10, 2019.

Thread Status:
Not open for further replies.
  1. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    Hi, still the same problem in Unity version 2019.4.3f1
    Code (CSharp):
    1. 2020/07/10 20:24:51.603 8430 8620 Error NdkMediaExtractor can't create http service
    2. 2020/07/10 20:24:51.603 8430 8620 Warn Unity AndroidVideoMedia: Error opening extractor: -10002
    3. 2020/07/10 20:24:51.603 8430 8620 Warn Unity (Filename:  Line: 469)
    4. 2020/07/10 20:24:51.603 8430 8620 Warn Unity
    5.  
    Screen Shot 2020-07-10 at 20.26.28.png
     
  2. gtara

    gtara

    Joined:
    Nov 5, 2015
    Posts:
    2
    Hi everyone. I have the same issue too.

    So can you reproduce a local video file with Videoplayer in Android 10?
    How did you fix it? :)

    Thanks
     
    Last edited: Jul 28, 2020
  3. Joy0023

    Joy0023

    Joined:
    Oct 30, 2017
    Posts:
    4
    Same issue Unity 2019.2.3f1, using both file from device and https url for Video player, same Exctractor error -10002,
    HELP
     
  4. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    Hi guys,

    I managed to fix this issue, in my case, the problem was "URL" for the final path I used:
    Code (CSharp):
    1. VideoPlayer.url = "file://" + _url;
    -I removed "file://" from the final path string and now all works perfectly.

    Hope this will help somebody!
     
    brazzoni likes this.
  5. gtara

    gtara

    Joined:
    Nov 5, 2015
    Posts:
    2
    Hi @InfinityCoder88 , thanks for the reply! :)
    I checked it but without any success. In my project i have built the path using Application.persistentDataPath, so it is like /storage/emulated/0/Android/data/<packagename>/files

    It didn't contain "file://", so probably the problem can't be there.
    Could you share the code of your working example please?

    If your application works on Android 10, maybe there are other things that hide the trick! :D

    Thank you very much!!
    Roberto
     
  6. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    Hi Roberto,

    In my project, I use Native Gallery for Android & iOS it's a free and very powerful plugin you can use to pick up files from native galleries on Android/iOS. In my case, another plugin overwrite the path by adding "file://" in URL.

    My workflow:

    My code:
    Code (CSharp):
    1. public void SelectVideoFromGallery()
    2. {
    3.             NativeGallery.GetVideoFromGallery(OnVideoPicked);
    4. }
    In Native Gallery:
    Code (CSharp):
    1. public static Permission GetVideoFromGallery( MediaPickCallback callback, string title = "", string mime = "video/*" )
    2.     {
    3.         return GetMediaFromGallery( callback, MediaType.Video, mime, title );
    4.     }
    5.  
    6.     private static Permission GetMediaFromGallery( MediaPickCallback callback, MediaType mediaType, string mime, string title )
    7.     {
    8.         Permission result = RequestPermission( true );
    9.         if( result == Permission.Granted && !IsMediaPickerBusy() )
    10.         {
    11. #if !UNITY_EDITOR && UNITY_ANDROID
    12.             string savePath;
    13.             if( mediaType == MediaType.Image )
    14.                 savePath = SelectedImagePath;
    15.             else if( mediaType == MediaType.Video )
    16.                 savePath = SelectedVideoPath;
    17.             else
    18.                 savePath = SelectedAudioPath;
    19.  
    20.             AJC.CallStatic( "PickMedia", Context, new NGMediaReceiveCallbackAndroid( callback, null ), (int) mediaType, false, savePath, mime, title );
    21. #elif !UNITY_EDITOR && UNITY_IOS
    22.             NGMediaReceiveCallbackiOS.Initialize( callback );
    23.             if( mediaType == MediaType.Image )
    24.                 _NativeGallery_PickImage( SelectedImagePath );
    25.             else if( mediaType == MediaType.Video )
    26.                 _NativeGallery_PickVideo( SelectedVideoPath );
    27.             else if( callback != null ) // Selecting audio files is not supported on iOS
    28.                 callback( null );
    29. #else
    30.             if( callback != null )
    31.                 callback( null );
    32. #endif
    33.         }
    34.  
    35.         return result;
    36.     }
    Hope this will help you, I highly recommend you to use this plugin!
     
  7. Wiedu

    Wiedu

    Joined:
    Jan 19, 2016
    Posts:
    7
    1. 2018.4.27f1 2019.4.12f1
    2.local mp4 file in Application.temporaryCachePath folder
    3. android 10 device

    it can not play,can any one help me
     
  8. Wiedu

    Wiedu

    Joined:
    Jan 19, 2016
    Posts:
    7
    PS. tes 2020.1.10f1 also fail,
    if the path have "file://" ,always show "can not read file"
    else do nothing and no error
     
  9. Wiedu

    Wiedu

    Joined:
    Jan 19, 2016
    Posts:
    7
    i found the problem and fix it
    but another question is when play the mp4 for a long time, the app will became very lag(in 2018.4.6 it can run nice)
     
  10. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    @Wiedu , did you tried to use more latest Unity versions 2019, 2020, and above?
    Maybe this issue is related to the old version of Unity!
     
  11. Wiedu

    Wiedu

    Joined:
    Jan 19, 2016
    Posts:
    7
    1.try 2019.4.13f1 & 2020.1.10 &2018.4.28f1
    2.test 4 mp4 file in local(about 20MB for each), and play in order
    3.run 24 hour at android 8 device and android 10 device
    4.sometimes it will lag,need to restart
    5.use 2018.4.28f1 Looks normal than other version,but still sometime lag
     
  12. TonyVT

    TonyVT

    Joined:
    Sep 11, 2014
    Posts:
    13
    @RoyalCoder you are great!
    I used your solution and it worked! Basically, I just did videoPlayer.url = new System.Uri(videoParts).ToString().Substring(7); where the Substring stuff removes the "file://" that breaks everything. That did the trick for me
     
    RoyalCoder likes this.
  13. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Did you manage to fix this? I'm having the same issues.

    @Domas_L any help?

    Getting this issue on Unity 2020.3 LTS on a Pixel 3A phone running Android 11. Using a video player with an url that is set like this with AppData.TrackingVideosDirectory being a persistent data path.

    Code (CSharp):
    1. VideoPlayer video = overlay.GetComponentInChildren<VideoPlayer>();
    2.             video.url = "file://" + Path.Combine(AppData.TrackingVideosDirectory, AppData.ActiveSessionData.sessionInfo.videoPath);
    3.             video.source = VideoSource.Url;
    4.             video.Prepare();


    Attempted Fixes
    1) Tried setting the URL both with a 'file://' prefix and without
    2) Tried this fix posted by Unity on the unity bug tracker page
    Unity Issue Tracker - [Android] Video is not being rendered when using URL on some Android devices (unity3d.com)
    By adding
    Code (CSharp):
    1. <application android:isGame="true" android:usesCleartextTraffic="true" />
    to the Android manifest file

    3) Tried adding the following permissions to the Android manifest file
    Code (CSharp):
    1. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    2.   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    None of these fixes worked.

    Numerous people are having this issue (see this thread). How can it be fixed?

    Both of Unity's answers are 'it's fixed' and 'by design' but I'm having this issue in 2020.3 and Unity's 'fix' does not work.

    Unity Issue Tracker - [Android] Video Player cannot play files located in the Persistent Data directory on Android 10 (unity3d.com)
    Unity Issue Tracker - [Android] Video is not being rendered when using URL on some Android devices (unity3d.com)
     
    Last edited: May 10, 2021
  14. Clashman

    Clashman

    Joined:
    Feb 18, 2019
    Posts:
    53
    I have the error "AndroidVideoMedia : No tracks in myFolder/myFile".
    I already removed "File//:" in my path.
    I use Unity 2019.3.15.
    Does a solution exist ?
     
    Last edited: Jul 23, 2021
Thread Status:
Not open for further replies.