【问题标题】:Google Mirror API Video谷歌镜像 API 视频
【发布时间】:2013-04-09 14:47:22
【问题描述】:

google glass mirror API 上的视频路线图是什么? API 是否允许像玻璃演示视频http://www.youtube.com/watch?v=v1uyQZNg2vE 中所示那样向设备传输视频或从设备传输视频?

【问题讨论】:

    标签: google-glass google-mirror-api


    【解决方案1】:

    镜像 API 没有发布的路线图。我们开发者预览版的部分动机是为了弄清楚这一点。

    首先,澄清一下,该视频中显示的流媒体是 Google+ 环聊。这是 Glass 内置的一项功能。

    更新:Glass 现在支持视频流。你可以找到完整的文档here

    要添加视频流,请制作一个多部分 POST,其中包含视频的 URL 作为部分之一,如下所示:

    POST /upload/mirror/v1/timeline HTTP/1.1
    Host: www.googleapis.com
    Authorization: Bearer {auth token}
    Content-Type: multipart/related; boundary="mymultipartboundary"
    Content-Length: {length}
    
    --mymultipartboundary
    Content-Type: application/json; charset=UTF-8
    
    { "text": "Skateboarding kittens" }
    --mymultipartboundary
    Content-Type: video/vnd.google-glass.stream-url
    
    http://example.com/path/to/kittens.mp4
    --mymultipartboundary--
    

    【讨论】:

    • 非常适合问题跟踪器。我认为在 Google 视频群聊期间添加推送卡片的功能会很棒。
    • 当尝试使用 video/vnd.google-glass.stream-url 时,内容永远不会播放。显示第一帧,加载动画永远运行。我们有没有机会看到一些代码示例添加到正在实施的文档中?
    • @PrplRugby - 我需要更多详细信息来帮助您解决问题。您介意创建一个新问题并包含您的代码和 JSON 有效负载吗?
    【解决方案2】:

    Youtube 视频流是可能的。我已经在 C#.net 中使用“YoutubeExtractor”命名空间完成了它。从您的管视频中解析视频(.mp4)网址并将其流式传输。这是代码。它对我来说很好。复制网址时,请点击分享后获取可用的 YouTube 链接

    private static String youtubevideoStream(MainController controller)
        {
    
            string link = "http://youtu.be/9uYKISlL7Vg";
            IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link);
            VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);
            String vLink = video.DownloadUrl;
    
    
            TimelineItem videocard= new TimelineItem()
            {
    
                Text = "Menu Card",
                BundleId = "666",
                Notification = new NotificationConfig() { Level = "DEFAULT" },
                MenuItems = new List<MenuItem>()
                                         {
                                             new MenuItem() {Action = "DELETE"},
                                         }
    
            };
    
            String mediaLink = vLink;
    
            if (!String.IsNullOrEmpty(mediaLink))
            {
                Stream stream = null;
                if (mediaLink.StartsWith("/"))
                {
                    stream = new StreamReader(controller.Server.MapPath(mediaLink)).BaseStream;
                }
                else
                {
                    HttpWebRequest request = WebRequest.Create(mediaLink) as HttpWebRequest;
    
                    request.UseDefaultCredentials = false;
    
    
                    HttpWebResponse response = request.GetResponse() as HttpWebResponse;
    
                    byte[] b = null;
                    using (Stream streamFromWeb = response.GetResponseStream())
                    using (MemoryStream ms = new MemoryStream())
                    {
                        int count = 0;
                        do
                        {
                            byte[] buf = new byte[1024];
                            count = streamFromWeb.Read(buf, 0, 1024);
                            ms.Write(buf, 0, count);
                        } while (streamFromWeb.CanRead && count > 0);
                        b = ms.ToArray();
    
                        stream = new MemoryStream(b);
                    }
                }
                controller.Service.Timeline.Insert(videocard, stream, "video/mp4").Upload();
            }
            else
            {
                controller.Service.Timeline.Insert(videocard).Fetch();
            }
    

    【讨论】:

      猜你喜欢
      • 2014-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-05
      • 1970-01-01
      • 2020-02-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多