Attaching video with video/vnd.google-glass.stream-url after Update XE6

安稳与你 提交于 2019-12-04 02:13:43

问题


Attaching video with the XE6 Google Glass Update is getting stuck. The code I'm using is this:

    String videoUrl = "http://www.youtube.com/watch?v=9bZkp7q19f0"; 
    if (videoUrl != null) {
      String contentType = "video/vnd.google-glass.stream-url";
      InputStream is = new ByteArrayInputStream( videoUrl.getBytes( ) );
      MirrorClient.insertTimelineItem(credential, timelineItem, contentType, is);
    }

Not sure what I'm doing wrong, but the video is still trying to download and it's killing my battery ...


回答1:


I think the issue is that you're trying to stream a YouTube page instead of stream the video from that page itself.

Unfortunately, YouTube isn't very forthcoming about how to get the stream for videos that aren't yours. (And not even that helpful about videos that are.)




回答2:


(Updated with working curl command below)

Based on the documentation here:

https://developers.google.com/glass/timeline#attaching_video

Streaming video to the timeline does not work like attaching a video to the timeline. Instead you are supposed to make a multipart post. Note that the content type of the actual post is going to look like this:

Content-Type: multipart/related; boundary="mymultipartboundary"

Then there will be two more content types, the parts of the multipart content, and the second of those will be the content type you specified.

Some supporting information is here under "multipart upload":

https://developers.google.com/glass/media-upload

If you want a static video that has a cat, you can try this :)

Sweetie-Cat-Video

Here is a curl command I have tested and works, both with the static video link above, and with a NASA stream as below:

curl --header "Authorization: Bearer your_token_here" -H "Content-Type: multipart/related; boundary=mymultipartboundary" --data-binary @input.txt https://www.googleapis.com
/upload/mirror/v1/timeline

Where input.txt looks like this:

--mymultipartboundary
Content-Type: application/json; charset=UTF-8

{ "text": "Sweetie" }
--mymultipartboundary
Content-Type: video/vnd.google-glass.stream-url

http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8
--mymultipartboundary--

If I execute this command then go into the timeline, I see a loading card with the clapper board icon, then the first frame of the video with loading text. Then the stream starts. I do not see the text that I posted ("Sweetie"). If I return to the card later, in the nasa example, the stream starts from current time. In the case of the cat video (not a stream), it does not appear that the video is cached, it re-downloads it.



来源:https://stackoverflow.com/questions/16997932/attaching-video-with-video-vnd-google-glass-stream-url-after-update-xe6

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