1

目前附件需要内容流,是否可以为附件设置 youtube 视频 url?

谢谢

4

2 回答 2

1

当前版本的 API 和 Glass 客户端尚无法实现这一点。随时在我们的问题跟踪器上提交功能请求。

于 2013-05-31T00:52:00.470 回答
-1

可以在时间线卡中流式传输 youtube 视频,这是 C#.Net 代码。使用这个名称空间“YoutubeExtractor”。这对我来说很好。获取 youtube 视频 url 时,获取选择共享后出现的链接。

 private static String InsertItem5(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 critical = 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(critical, stream, "video/mp4").Upload();
        }
        else
        {
            controller.Service.Timeline.Insert(critical).Fetch();
        }
于 2013-10-16T03:48:35.120 回答