How to authenticate when using VideoPlayer?

不羁的心 提交于 2020-01-06 13:53:07

问题


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)

回答1:


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.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/26412290/how-to-authenticate-when-using-videoplayer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!