Search Unity

Bug FatalError when calling playbackManager.SetPlaybackDatasetUri(datasetUri); on android

Discussion in 'AR' started by Intraterrestrial_, Aug 18, 2022.

  1. Intraterrestrial_

    Intraterrestrial_

    Joined:
    Jun 27, 2021
    Posts:
    20
    Hi, i am using the playback functionality of AR Core Extensions my code is as follows
    Code (CSharp):
    1. bool setPlaybackDataset = false;
    2.     float timeout;
    3.     Uri datasetUri;
    4.     public void loadSceneMP4(string path)
    5.     {
    6.         setPlaybackDataset = true;
    7.         m_Session.enabled = false;
    8.         timeout = 30f;
    9.         Debug.Log("Path mp4 "+ path);
    10.         if(File.Exists(@path)){
    11.             Debug.Log("Si Existe archivo");
    12.         }
    13.         else {
    14.             Debug.Log("No existe archivo");
    15.         }
    16.         //datasetUri = new System.Uri("file://"+path);
    17.    
    18.         bool result = Uri.TryCreate(@"file://"+path, UriKind.Absolute, out datasetUri)
    19.             && (datasetUri.Scheme == Uri.UriSchemeFile);
    20.         if (result)
    21.             Debug.Log("Uri valida");
    22.         else
    23.             Debug.Log("Uri invalida");
    24.  
    25.         Debug.Log("URI DIR: "+ datasetUri.LocalPath);
    26.     }
    27.  
    28.     void Update(){
    29.         if (setPlaybackDataset){
    30.             PlaybackResult result = playbackManager.SetPlaybackDatasetUri(datasetUri);
    31.             if (result == PlaybackResult.ErrorPlaybackFailed){
    32.                 timeout -= Time.deltaTime;
    33.                 Debug.Log("Session error playback");
    34.             }
    35.             else if (result == PlaybackResult.SessionNotReady){
    36.                 timeout -= Time.deltaTime;
    37.                 Debug.Log("SessionNotReady");
    38.             }
    39.             else if(result == PlaybackResult.ErrorSessionUnsupported){
    40.                 Debug.Log("ErrorSessionUnsupported");
    41.             }
    42.             else if(result == PlaybackResult.ErrorSessionNotPaused){
    43.                 Debug.Log("ErrorSessionNotPaused");
    44.             }
    45.             else{
    46.                 timeout = -1f;
    47.             }
    48.  
    49.             if (timeout < 0.0f)
    50.             {
    51.                 m_Session.enabled = true;
    52.                 setPlaybackDataset = false;
    53.                 //error o se logro
    54.             }
    55.         }
    56.     }
    57.  
    Variable path is called and has the following value "/device_storage/DCIM/ARproject/videos/17-08-2022-18-05-50.mp4"

    at first it says SessionNotReady then after a few seconds throws this error

    Playback dataset failed with unexpected status: ErrorFatal

    Google.XR.ARCoreExtensions.Internal.Translators:ToPlaybackResult(ApiArStatus)
    ScreenR2:Update()


    For some reason when i try File.Exists(@Path) it says that file doesnt exists, i already try to put a "@" to file path but that doesnt work either, but when i try Uri.TryCreate and the other stuff, it says uri is correct.
    The file mp4 is in the directory, directory is correct... but for some reason i cant make it work, also i verified the "file://" of android (it only has two because my path variable starts with a "/") and is correct, i already search but i didnt find any info so i am asking here if anyone knows a solution, thanks.
     
    Last edited: Aug 18, 2022
  2. Intraterrestrial_

    Intraterrestrial_

    Joined:
    Jun 27, 2021
    Posts:
    20
    After several testing i found that it was the path, in order to make it work i had to use it as follows:

    /storage/emulated/0/DCIM/ARproject/videos/18_08_2022_16_11_56.mp4
    not like:
    /device_storage/DCIM/ARproject/videos/18_08_2022_16_11_56.mp4

    i had to be as symlink

    so in order to make it work i did this code:

    Code (CSharp):
    1. string pathFix =  path;
    2. pathFix =  pathFix.Replace("/device_storage/", "/storage/emulated/0/");
    i am stil testing it so maybe i will have to add more code to fix the issue in all phones