2014-02-18 3 views
1

내 앱에 YouTube Android Player API을 성공적으로 통합했습니다. 어떤 파일이 플레이어에서 렌더링되는지 궁금합니다. 모든 단일 비디오 파일은 320dpi, 720dpi, & 등의 여러 형식을 가질 수 있습니다.android에서 재생하고 재생할 파일 which youtube player

내 사용자가 더 낮은 대역폭에있는 경우; 파일 형식을 선택하거나 API가 자동으로 해당 버전 및 부사에서 재생할 버전을 검색 할 수 있습니다. 내 코드 :

public class YoutubeVideoActivity extends YouTubeBaseActivity implements 
     YouTubePlayer.OnInitializedListener, YouTubePlayer.OnFullscreenListener { 

    Activity activity = YoutubeVideoActivity.this; 

    public static final String API_KEY = "AIzaSyDN6Q9Pv4seQZqIcjB*********Po5k"; 
    // public static final String VIDEO_ID = "psY0Botpi84"; 

    public String new_id; 
    private boolean fullscreen; 
    private YouTubePlayerView playerView; 

    @Override 
    protected void onCreate(Bundle arg0) { 

     super.onCreate(arg0); 
     // Remove title bar 
     this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
     setContentView(R.layout.activity_youtube_video); 
     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 

     Intent intent = getIntent(); 
     String video_link = intent.getExtras().getString("video_link"); 

     try { 
      new_id = video_link.substring("http://www.youtube.com/watch?v=" 
        .length()); 
      if (new_id.equals("")) { 
       IndepententTVUtils.showCustomAlert(activity, 
         "Data is not availble. Press back key", 
         R.drawable.ic_new_launcher); 
      } else { 
       playerView = (YouTubePlayerView) findViewById(R.id.youtubeplayerview); 
       playerView.initialize(API_KEY, this); 
      } 

     } catch (Exception e) { 

      IndepententTVUtils.showCustomAlert(activity, 
        "Data is not availble", R.drawable.ic_new_launcher); 
     } 

    } 

    @Override 
    public void onInitializationFailure(Provider arg0, 
      YouTubeInitializationResult arg1) { 

     Toast.makeText(getApplicationContext(), 
       "To See this Video, Install Latest YouTube Application", 
       Toast.LENGTH_LONG).show(); 

    } 

    @Override 
    public void onInitializationSuccess(Provider arg0, YouTubePlayer player, 
      boolean wasRestored) { 

     player.setOnFullscreenListener(this); 

     if (!wasRestored && new_id != null) { 

      player.cueVideo(new_id); 

     } 

    } 

    @Override 
    public void onFullscreen(boolean isFullscreen) { 

     fullscreen = isFullscreen; 

    } 

} 

답변

1

플레이어는 설정 비디오 품질을 자동으로 사용자에 따라 대역폭하거나 아니었다면 인터넷 속도, 그래서 플레이어에서은 setPlaybackQuality을 지정하는 옵션이있을 것입니다. 플레이어 설정을 변경하는 데 제한적인 옵션이 있습니다. here

+0

감사합니다 ... 어디에서 setPlaybackQuality를 찾았습니까? 어떻게하면 플레이어가 사용자의 대역폭이나 인터넷 속도에 따라 자동으로 비디오 화질을 설정합니까? –