1

Currently attachment takes stream for the content, is it possible to set a youtube video url for the attachment?

Thanks

Snekithan
  • 360
  • 3
  • 11
  • Check out this very similar question: http://stackoverflow.com/questions/16049889/google-mirror-api-video/16050044#16050044 – mimming Jun 05 '13 at 04:40

2 Answers2

1

This is not yet possible with the current version of the API and Glass client. Feel free to file a feature request on our issues tracker.

Alain
  • 6,044
  • 21
  • 27
-1

It is possible to stream a youtube video in the timeline card, here is the C#.Net code. use this name space "YoutubeExtractor".This works fine for me. When getting the youtube video url get the link that comes after you select share.

 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();
        }
Amalan Dhananjayan
  • 2,277
  • 1
  • 34
  • 47