4

I've been having some issues while trying to play video via the Oculus mobile sdk MediaSurfacePlugin for Unity. I've tried lots of different ideas but keep coming back to the same problem; It seems like the Android mediaplayer can't find the file. These are the most common errors I've been getting:

Unity : Failed to start mediaPlayer with message java.io.IOException: setDataSource failed.

Unity :

Unity : (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

Unity :

and

MediaPlayer: Unable to create media player

Unity : Failed to start mediaPlayer with message java.io.IOException: setDataSourceFD failed.: status=0x80000000

Unity :

Unity : (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

Unity :

As well as; mediaplayer prepare failed. status=0x1.

As far as I can tell they all mean that either mediaplayer cant get access to the file or cant find the file, or that it cant play the file due to incompatible format (I'm fairly certain that my files are compatible; .ogv format, I've also tried .mp4). I've been storing my files in the streamingassets folder of unity, I think this the correct place to put them?

My software versions are; ovr_sdk_mobile_1.0.3 and Unity v5.3.6f1, Oculus Utilities v1.7.0, OVRPlugin v1.5.0, SDK v1.0.3.1.

What I've tried:

  • Different video format: tried big_buck_bunny.mp4, no difference
  • Appending the video format/taking it away: no difference
  • I also tried using the file descriptor constructor for mediaplayer as opposed to the string, this is awkward to do through unity and it didn't seem to make a difference,this is the code I used for that, tried both with and without the appended file extension:

    AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
    AndroidJavaObject context = activity.Call<AndroidJavaObject>("getApplicationContext");
    AndroidJavaObject assets = context.Call<AndroidJavaObject>("getAssets");
    AndroidJavaObject descriptor = assets.Call<AndroidJavaObject>("openFd", movieName+".ogv");
    mediaPlayer.Call("setDataSource", new object[]{descriptor.Call<object>("getFileDescriptor"),descriptor.Call<object>("getStartOffset"),descriptor.Call<object>("getLength")});
    
  • It says in the sdk readme for the MediaSurfacePlugin to use IntPtr androidSurface = OVR_Media_Surface(textureId, 2880, 1440);

However this method doesn't seem to exist(?), so I used the below code which seems to work:

OVR_Media_Surface_SetTextureId(texId);
OVR_Media_Surface_SetTextureParms(960, 540);//960/540 is the video resolution
IntPtr androidSurface =  OVR_Media_Surface_GetObject();
  • A post on the oculus forums a while ago mentioned trying using the callvoidmethod as opposed to callobjectmethod, tried that, didn't seem to change anything:

    AndroidJNI.CallObjectMethod(mediaPlayer.GetRawObject(), setSurfaceMethodId, parms);
    // AndroidJNI.CallVoidMethod(mediaPlayer.GetRawObject(), setSurfaceMethodId, parms);
    
  • I've also seen people suggest turning off multithreading in the Unity settings for android; again this didn't seem to make a difference.

I'd really appreciate any help here, I feel like I've tried everything at this point!

Has anyone successfully gotten this working?

Umair M
  • 10,298
  • 6
  • 42
  • 74
AarnemK
  • 41
  • 1

0 Answers0