cancel
Showing results for 
Search instead for 
Did you mean: 

Movie Playing in UnitySDK

smx
Honored Guest
In the sample scene "MoviePlayer_Sample" offered by Oculus in the UnitySDK:

I cannot play a movie. Although I changed

mediaPlayer.Call( "setDataSource", "/sdcard/oculus/Movies/Trailers/Night_of_the_living_Dead.mp4" );
to an existing movie it doesn't play the movie.

Also it says: "NOTE: The resolution of the movie texture is hard coded to 960x540 in MediaSurface.cpp."

How can I change that to 4096x2048 video @ 30 FPS or a
2048x2048 video @ 60 FPS as hinted at in the docs.


Thanks!
38 REPLIES 38

leftbigtoe
Protege
sweet, got it running. had to disable the maven plugin (this thing was actually quite useful configuring to configure NDK, SDK and eclipse http://www.gearvrf.org/bin/view/GearVRfDeveloperGuide/GearVRfDevGuide200Start

ran into the next problem though: movie is playing fine on a Note 4 running Android 5.0.1 but nothing happens on a S6 with Android 5.0.2 (both built with Unity 5.0.2 and the Oculus SDK 0.5.1). Scene starts up, one sees the initial texture but the movie never starts playing.
Checked the adb logcat output for Unity and the MediaPlayer couldn't find any error messages, the only difference between the Note 4 where it runs and S6 where it doesn't was this mysterious line saying "No OnVrApiEvent delegate set!" from the OVRManager - not sure if that has anything to do with that.

If I had to guess I'd say it's either some weird difference between the Android versions or some weird path issue...although you would expect some error messages in that case. Has anybody experienced something similar?

Hirdannen
Protege
That's weird. Did you use the S6 with other GearVR apps ?

Do you have all the traditional MediaPlayer messages (when it loads the media, etc...) ?

It might be indeed a path problem, since things like /sdcard/ or /extSdcard/ can change between phones.

The video does not play.. But do you see the app launching ? Are you in the app ? If yes, then my guess is that it must be definitely a path problem.

leftbigtoe
Protege
S6 works fine for everything else and I indeed get in the app, only the movie does not start.

I get all the normal MediaPlayer messages EXCEPT this one (that I get on the Note4):
E/MediaPlayer(23595): setDataSource replace URI : /storage/extSdCard/


Trying to use a FileDescriptor instead of a path with your code from the other thread (https://forums.oculus.com/viewtopic.php?t=21265), no luck so far though. Is there an easy way to get an file descriptor from any path and also check if it is readable? Still new to interfacing with the Java code directly...

UPDATE: so I checked some stuff. I can definitely find the file, the following code within awake returns true:

string path = "/storage/sdcard0/Oculus/360Videos/test_video.mp4";
bool fileTest = new AndroidJavaObject ("java/io/File", path).Call<bool>("exists");
Debug.Log ((fileTest ? "found " : "could not find ") + path);


I use the following method to get a fileDescriptor:

public static AndroidJavaObject fileDescriptorFromPath(string path){
Debug.Log ("opening file descriptor");
AndroidJavaObject fd = new AndroidJavaObject ("java/io/FileInputStream", (new AndroidJavaObject ("java/io/File", path))
).Call<AndroidJavaObject>("getFD");
Debug.Log ("fd toString output: " + fd.Call<String> ("toString"));
Debug.Log ("fd is: " + (fd.Call<bool> ("valid") ? "valid" : "invalid"));
if (fd != null) {
Debug.Log ("successfully created a file descriptor");
return fd;
} else {
Debug.Log ("something went wrong, fileDescriptor is null");
return null;
}
}


I pass this file descriptor to the SetDataSource method, using the code from the sample provided by the SDK:


AndroidJavaObject StartVideoPlayerOnTextureId(int textureId)
{
Debug.Log("SetUpVideoPlayer ");

IntPtr androidSurface = OVR_Media_Surface(textureId);

AndroidJavaObject mediaPlayer = new AndroidJavaObject("android/media/MediaPlayer");

// Can't use AndroidJavaObject.Call() with a jobject, must use low level interface
//mediaPlayer.Call("setSurface", androidSurface);
IntPtr setSurfaceMethodId = AndroidJNI.GetMethodID(mediaPlayer.GetRawClass(),"setSurface","(Landroid/view/Surface;)V");
jvalue[] parms = new jvalue[1];
parms[0] = new jvalue();
parms[0].l = androidSurface;
AndroidJNI.CallObjectMethod(mediaPlayer.GetRawObject(), setSurfaceMethodId, parms);

//############# set movie path here ####################
Debug.Log("movie player trying to open file...");

mediaPlayer.Call("setDataSource", fileDescriptorFromPath("/storage/sdcard0/Oculus/360Videos/test_video.mp4"));

mediaPlayer.Call("prepare");
mediaPlayer.Call("setLooping", true);
Debug.Log("starting player");
mediaPlayer.Call("start");
Debug.Log("called start, movie should run");

return mediaPlayer;
}


and just for the sake of completeness, the logcat output:

--------- beginning of system
D/Unity (10109): GL_EXT_debug_marker GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_debug GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage GL_EXT_multisampled_render_to_texture GL_OES_surfaceless_context GL_OES_texture_stencil8 GL_EXT_shader
D/Unity (10109): _pixel_local_storage GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_ARM_mali_program_binary GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_texture_sRGB_decode GL_KHR_blend_equation_advanced GL_OES_texture_storage_multisample_2d_array GL_OES_shader_image_atomic
I/Unity (10109): Unity Version: 5.0.2f1
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): Inhibiting Entitlement Check!
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): Creating volume controller...
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): Awake
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): external dir path: /storage/emulated/0
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): found /storage/sdcard0/Oculus/360Videos/video_test.mp4
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): Movie Texture id: 22
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): OnApplicationFocus() True
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): SetUpVideoPlayer
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/MediaPlayer(10109): Need to enable context aware info
I/Unity (10109): movie player trying to open file...
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): opening file descriptor
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): fd toString output: FileDescriptor[61]
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): fd is: valid
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): successfully created a file descriptor
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
E/MediaPlayer(10109): Should have subtitle controller already set
E/MediaPlayer(10109): Should have subtitle controller already set
I/Unity (10109): starting player
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
W/MediaPlayer(10109): this is IMEDIA_PLAYER_VIDEO_EXIST
I/MediaPlayer(10109): sendBroadcast android.media.IMediaPlayer.videoexist
I/Unity (10109): called start, movie should run
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/MediaPlayer(10109): send context aware event
I/MediaPlayer(10109): sendBroadcast CONTEXT_AWARE_MUSIC_INFO - type(start) - id (40)
W/MediaPlayer(10109): this is IMEDIA_PLAYER_VIDEO_EXIST
I/MediaPlayer(10109): sendBroadcast android.media.IMediaPlayer.videoexist
W/MediaPlayer(10109): info/warning (3, 0)
I/Unity (10109): OnApplicationPause() True
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/Unity (10109): OnApplicationPause: True
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
I/MediaPlayer(10109): sendBroadcast CONTEXT_AWARE_MUSIC_INFO - type(pause) - id(40)
I/Unity (10109): OnApplicationFocus() False
I/Unity (10109):
I/Unity (10109): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
I/Unity (10109):
W/MediaPlayer( 3877): info/warning (973, 0)
E/MediaPlayer( 3877): Should have subtitle controller already set
I/MediaPlayer( 3877): sendBroadcast CONTEXT_AWARE_MUSIC_INFO - type(release) - id(39)
E/MediaPlayer( 3877): Should have subtitle controller already set
I/MediaPlayer( 3877): send context aware event
I/MediaPlayer( 3877): sendBroadcast CONTEXT_AWARE_MUSIC_INFO - type(start) - id (41)
I/MediaPlayer( 3877): sendBroadcast CONTEXT_AWARE_MUSIC_INFO - type(complete) - id(41)


any ideas? this is driving me crazy...

cbleser
Honored Guest
My Application crashes in the sample scene "MoviePlayer_Sample" offered by Oculus in the UnitySDK:

After loading i become a message and the Sample is closing. The only diference to the previus posts is, in logcat i have
the message - E/Unity (12569): Unable to find OculusInitPlugin -

Has anybody a idea? i am trying to solve the issue since 8h.

Hirdannen
Protege
I don't think you need a filedescriptor towards your desired file as long as you're not targeting a file inside the APK. Moreover, it is not the same " setDataSource" function than the one using a path. In the path, you mentioned, I show how to retrieve the "setDataSource" function for filedescriptors.

Have you build yourself any other GearVR app on the S6 ? Do you have the signature file ? (jsut asking, we never know)

leftbigtoe
Protege
I managed to finally solved the issue - the fix being something quite unexpected:
I had the texture compression settings on "Don't override" and as soon as I set them to GLES 3.0 the whole thing started working.

really weird since the scene itself started up, it was just the movie that was not playing before. surprised that a texture compression setting could fix that. SDK vodoo I guess...

Hirdannen
Protege
Ah... Saw some other posts talking about problems with GLES & S6...

Good to keep that in mind, thanks for going through all the trouble for the rest of us 😉

Anonymous
Not applicable
Hey everyone !

I downloaded the latest sdk (0.6.0), and I have troubles getting decent 360 video quality (even at 4k) with the MoviePlayerSample.cs script in Unity.

As suggested in the .cs file and in your previous posts, I searched for the MediaSurface.cpp file in the sdk, but couldn't find it in the 0.6.0 revision.

Has the file name and/or path changed ?

akarioculus
Honored Guest
"TNTantoine" wrote:
Hey everyone !

I downloaded the latest sdk (0.6.0), and I have troubles getting decent 360 video quality (even at 4k) with the MoviePlayerSample.cs script in Unity.

As suggested in the .cs file and in your previous posts, I searched for the MediaSurface.cpp file in the sdk, but couldn't find it in the 0.6.0 revision.

Has the file name and/or path changed ?


Same problem;(

Does any of you have the answer?

Anonymous
Not applicable
I think it's been moved to the VrApi which as of 0.6.0:

"