How to authenticate when using VideoPlayer?

2019-08-30 17:53发布

I am implementing the following solution Play a video in Glass

Intent i = new Intent();
i.setAction("com.google.glass.action.VIDEOPLAYER");
i.putExtra("video_url", "..."); 
startActivity(i); 

But I am getting hit with a 401 error.

To authenticate I need to include my key/value pair in header.

How do I go about doing that, with intents?

10-16 14:58:55.229    126-10199/? I/ChromiumHTTPDataSourceSupport﹕ Server responded with http status 401
10-16 14:58:55.229    126-10470/? I/AwesomePlayer﹕ mConnectingDataSource->connect() returned -1004
10-16 14:58:55.229  10175-10216/? E/MediaPlayer﹕ error (1, -1004)
10-16 14:58:55.237  10175-10197/? W/VideoPlayer﹕ Failed to start playback.
    java.io.IOException: Prepare failed.: status=0x1
            at android.media.MediaPlayer.prepare(Native Method)
            at com.google.glass.videoplayer.VideoPlayer$4.serialDoInBackground(SourceFile:577)
            at com.google.glass.videoplayer.VideoPlayer$4.serialDoInBackground(SourceFile:463)
            at com.google.glass.async.SerialAsyncTask.doInBackground(SourceFile:59)
            at android.os.AsyncTask$2.call(AsyncTask.java:302)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at com.google.glass.async.PriorityThreadFactory$1.run(SourceFile:39)
            at java.lang.Thread.run(Thread.java:841)

3条回答
走好不送
2楼-- · 2019-08-30 18:38

Currently (only for testing) I made the token a query parameter, and authenticated through that.

查看更多
闹够了就滚
3楼-- · 2019-08-30 18:48

The com.google.glass.action.VIDEOPLAYER Intent is an undocumented Intent that is likely to change without any notice. There's no official support for it, thus no authentication.

If you need video playback capability, I strongly recommend that you follow this feature request.

查看更多
【Aperson】
4楼-- · 2019-08-30 18:48

Hi prepare method of mediaplayer fails if you call it before setting the datasource or if setdatasource fails Try changing the url

查看更多
登录 后发表回答