@Override public boolean onKeyDown(int keyCode, KeyEvent event) { boolean managerKeyDown = basePlayerManager.onKeyDown(keyCode, event); if (basePlayerManager.shouldCallSuperKeyDown()) { return super.onKeyDown(keyCode, event); } else { return managerKeyDown; } }
@Override public void onBackPressed() { // android系统调用 Logger.d("sgh", "onBackPressed before super"); super.onBackPressed(); Logger.d("sgh", "onBackPressed"); basePlayerManager.onBackPressed(); }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.player); initView(); basePlayerManager = new YoukuBasePlayerManager(this) { @Override public void setPadHorizontalLayout() { // TODO Auto-generated method stub } @Override public void onInitializationSuccess(YoukuPlayer player) { // TODO Auto-generated method stub // 初始化成功后需要添加该行代码 addPlugins(); // 实例化YoukuPlayer实例 youkuPlayer = player; // 进行播放 goPlay(); } @Override public void onSmallscreenListener() { // TODO Auto-generated method stub } @Override public void onFullscreenListener() { // TODO Auto-generated method stub } }; basePlayerManager.onCreate(); // 通过上个页面传递过来的Intent获取播放参数 getIntentData(getIntent()); if (TextUtils.isEmpty(id)) { vid = "XODQwMTY4NDg0"; // 默认视频 } else { vid = id; } // 播放器控件 mYoukuPlayerView = (YoukuPlayerView) this.findViewById(R.id.full_holder); // 控制竖屏和全屏时候的布局参数。这两句必填。 mYoukuPlayerView.setFullScreenLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); mYoukuPlayerView.setSmallScreenLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); // 初始化播放器相关数据 mYoukuPlayerView.initialize(basePlayerManager); }
@Override protected void onStop() { super.onStop(); basePlayerManager.onStop(); }
@Override public boolean onSearchRequested() { // android系统调用 return basePlayerManager.onSearchRequested(); }
@Override protected void onResume() { super.onResume(); basePlayerManager.onResume(); }
@Override protected void onPause() { super.onPause(); basePlayerManager.onPause(); }
@Override public void onLowMemory() { // android系统调用 super.onLowMemory(); basePlayerManager.onLowMemory(); }
@Override protected void onDestroy() { super.onDestroy(); basePlayerManager.onDestroy(); }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); basePlayerManager.onConfigurationChanged(newConfig); }