Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Video error VideoPlayer on Android

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

  1. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    286
    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:
    286
    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!
     
  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:
    286
    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:
    286
    @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:
    10
    @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.
unityunity