2016-04-18 72 views

回答

0

根据此documentation,您需要调用captions.list方法来检索可用于特定视频的字幕轨道列表。将videoId参数值设置为唯一标识您检索字幕的视频的YouTube视频ID。

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.captions.list?part=snippet&videoId=PRU2ShMzQRg 

这里是一个example演示如何使用API​​方法来创建和管理的YouTube视频的字幕轨道。

选中此相关的SO问题:How to add Captions to Youtube video using Youtube API v3?

UPDATE:

检查这个example

/** 
    * Returns a list of caption tracks. (captions.listCaptions) 
    * 
    * @param videoId The videoId parameter instructs the API to return the 
    * caption tracks for the video specified by the video id. 
    * @throws IOException 
    */ 
    private static List<Caption> listCaptions(String videoId) throws IOException { 
     // Call the YouTube Data API's captions.list method to 
     // retrieve video caption tracks. 
     CaptionListResponse captionListResponse = youtube.captions(). 
      list("snippet", videoId).execute(); 

     List<Caption> captions = captionListResponse.getItems(); 
     // Print information from the API response. 
     System.out.println("\n============ Returned Caption Tracks ============\n"); 
     CaptionSnippet snippet; 
     for (Caption caption : captions) { 
      snippet = caption.getSnippet(); 
      System.out.println(" - ID: " + caption.getId()); 
      System.out.println(" - Name: " + snippet.getName()); 
      System.out.println(" - Language: " + snippet.getLanguage()); 
      System.out.println("\n----------------------------------------------\n"); 
     } 

     return captions; 
    } 
+0

感谢@abielita,打电话给captions.list方法后,我收到了这样的: [链接](http://imgur.com/mBUy18e)**在这里显示图像** 如何从此结果中获取列表标题? –

+0

请告诉我如何在调用captions.list方法后从结果中检索列表标题? 在调用captions.list方法后,我收到了[像这样的结果](https://www.googleapis.com/youtube/v3/captions?part=snippet&videoId=PRU2ShMzQRg&fields=etag%2CeventId%2Citems%2Ckind%2CvisitorId&key=AIzaSyACXxwTh1iOSpgKGDVkXRJcsbRN19j2_nk ) –

+0

请检查我的更新答案。让我知道它是否有效。 – abielita

相关问题