4

I'm trying to play a local video (mp4) on Google Glass using VIDEOPLAYER.

My code is:

Intent i = new Intent();
i.setAction("com.google.glass.action.VIDEOPLAYER");
i.putExtra("video_url", "android.resource://" + getPackageName() +"/"+R.raw.close_upper_case_mp4); 
startActivity(i);   

When I launch the code (on "startActivity(i)"), I get:

java.lang.NullPointerException
at org.eclipse.debug.internal.ui.DebugUIPlugin.launchInBackground(DebugUIPlugin.java:1257)
at org.eclipse.debug.ui.DebugUITools.launch(DebugUITools.java:757)
at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.debugRunningApp(AndroidLaunchController.java:176)
at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.clientChanged(AndroidLaunchController.java:1742)
at com.android.ddmlib.AndroidDebugBridge.clientChanged(AndroidDebugBridge.java:912)
at com.android.ddmlib.Device.update(Device.java:600)
at com.android.ddmlib.Client.update(Client.java:903)
at com.android.ddmlib.HandleWait.handleWAIT(HandleWait.java:88)
at com.android.ddmlib.HandleWait.handleChunk(HandleWait.java:66)
at com.android.ddmlib.MonitorThread.callHandler(MonitorThread.java:414)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:322)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)

and it seems like the Glass is loading something but nothing happens.

I think that the path is not correct, because I tried other things (like MediaPlayer) and I get the same result.

Any clues?

MosheS
  • 103
  • 1
  • 6

2 Answers2

1

According to this answer, you have to set the path like this:

"android.resource://[package]/[res type]/[res name]"

so it would be

"android.resource://" + getPackageName() +"/raw/" + R.raw.close_upper_case_mp4

It may also be that the path is not properly encoded, try

Uri.parse("android.resource://" + getPackageName() +"/raw/" + R.raw.close_upper_case_mp4).toString();

(with or without the "/raw" part)

Community
  • 1
  • 1
  • It seems that adding the "/raw/" doesn't change anything. – MosheS Mar 31 '14 at 12:57
  • I added the code mentioned in the link: int test = this.getResources().getIdentifier("close_upper_case_mp4", "raw", this.getPackageName()); if (test != 0) { result = true; } and "test" was not 0, do I have no idea what is the issue here. – MosheS Mar 31 '14 at 12:58
0

I faced the same issue. com.google.glass.action.VIDEOPLAYER does not access local resources of the project. you can solve this by using video view or place your video on the external storage directory of the glass.

Mohanad Haddadin
  • 569
  • 6
  • 15