2014-03-25 123 views
1

我使用Google API來呈現youtube視頻。 Ißm嘗試使用seekToMillis()尋求特定的時間,但視頻始終從頭開始。Android API seekToMillis()需要說明

代碼:

youTubePlayerView.initialize(API_KEY, new YouTubePlayer.OnInitializedListener() { 

     public void onInitializationSuccess(Provider arg0, YouTubePlayer player, boolean arg2) { 
      youTubePlayer = player; 
      youTubeThumbnailView.setVisibility(View.GONE); 
      youTubePlayerView.setVisibility(View.VISIBLE); 
      youTubePlayer.loadVideo("o7VVHhK9zf0"); 
      youTubePlayer.seekToMillis(50000); 



     } 

     public void onInitializationFailure(Provider arg0, YouTubeInitializationResult arg1) { 
      youTubePlayerView.setVisibility(View.GONE); 
     } 
    }); 

回答

3

如果你想,而不是開始在特定位置的影像,使用此方法:

YouTubePlayer.loadVideo(String videoId, int timeMillis)

From here

加載並播放指定的視頻播放將在視頻中的指定時間開始播放。

+0

...有時我忽略了這樣的簡單的事情:/ – Emaborsa