2013-05-30 33 views

回答

1

這是沒有可能的API和玻璃客戶端的當前版本。請隨時在我們的issues tracker上提交功能請求。

-1

可以在時間線卡上傳輸YouTube視頻,這裏是C#.Net代碼。使用這個名字空間「YoutubeExtractor」。這對我來說很好。在獲取YouTube視頻網址後,獲取選擇共享後的鏈接。

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(); 
     } 
相關問題