@Override public void onCreate() { TvApplication.setCurrentRunningProcess(this, false); super.onCreate(); if (DEBUG) Log.d(TAG, "onCreate"); mChannelDataManager = new ChannelDataManager(getApplicationContext()); mAudioCapabilitiesReceiver = new AudioCapabilitiesReceiver(getApplicationContext(), this); mAudioCapabilitiesReceiver.register(); mBufferManager = createBufferManager(); if (CommonFeatures.DVR.isEnabled(this)) { JobScheduler jobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); JobInfo pendingJob = jobScheduler.getPendingJob(DVR_STORAGE_CLEANUP_JOB_ID); if (pendingJob != null) { // storage cleaning job is already scheduled. } else { JobInfo job = new JobInfo.Builder(DVR_STORAGE_CLEANUP_JOB_ID, new ComponentName(this, TunerStorageCleanUpService.class)) .setPersisted(true).setPeriodic(TimeUnit.DAYS.toMillis(1)).build(); jobScheduler.schedule(job); } } if (mBufferManager == null) { Log.i(TAG, "Trickplay is disabled"); } else { Log.i(TAG, "Trickplay is enabled"); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EpisodeBaseModel episode = (EpisodeBaseModel) getIntent().getSerializableExtra(ContentManagerBase.CONTENT_ID); mOtherEpisodeUrls = Arrays.asList(getIntent().getStringArrayExtra(ContentManagerBase.OTHER_EPISODES)); resumePosition = getIntent().getLongExtra(RESUME_POSITION, 0); if (resumePosition <= 0 && episode.getResumePosition() > 0) { resumePosition = episode.getResumePosition(); Log.d(TAG, "Resume from recently played"); } setContentView(R.layout.video_player_activity); View root = findViewById(R.id.root); mediaController = new PlaybackControls(this); mediaController.setAnchorView(root); videoPlayerView = new VideoPlayerView(this, mediaController, root); audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(getApplicationContext(), this); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) { CookieHandler.setDefault(defaultCookieManager); } playEpisode(episode); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_player); View root = findViewById(R.id.root); root.setOnTouchListener((view, motionEvent) -> { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { toggleControlsVisibility(); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { view.performClick(); } return true; }); root.setOnKeyListener((v, keyCode, event) -> !(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_MENU) && mediaController.dispatchKeyEvent(event)); shutterView = findViewById(R.id.shutter); videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame); surfaceView = (SurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles); mediaController = new KeyCompatibleMediaController(this); mediaController.setAnchorView(root); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) { CookieHandler.setDefault(defaultCookieManager); } audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this); audioCapabilitiesReceiver.register(); }
public void replaceRenderBuilder(@Nullable RenderBuilder renderBuilder) { this.rendererBuilder = renderBuilder; if (rendererBuilder != null && audioCapabilities == null) { audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(rendererBuilder.getContext(), this); audioCapabilitiesReceiver.register(); } prepared = false; prepare(); }
protected void setup() { audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(getContext().getApplicationContext(), this); audioCapabilitiesReceiver.register(); emExoPlayer = new EMExoPlayer(null); //Sets the internal listener emExoPlayer.setMetadataListener(null); setSurfaceTextureListener(new EMExoVideoSurfaceTextureListener()); updateVideoSize(0, 0); }
/** * 初始化播放器 */ private void initExoPlayer() { audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(getContext().getApplicationContext(), this); audioCapabilitiesReceiver.register(); okPlayer = new OkPlayer(null); okPlayer.addListener(this); okPlayer.setId3MetadataListener(null); okPlayer.setSurface(surfaceView.getHolder().getSurface()); surfaceView.getHolder().addCallback(this); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // TODO: // setContentView(R.layout.player_activity); setContentView(R.layout.player_activity_two); root = findViewById(R.id.root); root.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { toggleControlsVisibility(); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { view.performClick(); } return true; } }); root.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_MENU) { return false; } // TODO: return mediaController.dispatchKeyEvent(event); return goatMediaController.dispatchKeyEvent(event); } }); shutterView = findViewById(R.id.shutter); debugRootView = findViewById(R.id.controls_root); videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame); surfaceView = (SurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); debugTextView = (TextView) findViewById(R.id.debug_text_view); playerStateTextView = (TextView) findViewById(R.id.player_state_view); subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles); // TODO: // mediaController = new MediaController(this); // mediaController.setAnchorView(root); goatMediaController = (GoatMediaController) findViewById(R.id.media_controller); retryButton = (Button) findViewById(R.id.retry_button); retryButton.setOnClickListener(this); videoButton = (Button) findViewById(R.id.video_controls); audioButton = (Button) findViewById(R.id.audio_controls); textButton = (Button) findViewById(R.id.text_controls); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) { CookieHandler.setDefault(defaultCookieManager); } audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this); audioCapabilitiesReceiver.register(); getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(this); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.player_activity); View root = findViewById(R.id.root); root.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { toggleControlsVisibility(); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { view.performClick(); } return true; } }); root.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_MENU) { return false; } return mediaController.dispatchKeyEvent(event); } }); shutterView = findViewById(R.id.shutter); debugRootView = findViewById(R.id.controls_root); videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame); surfaceView = (SurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); debugTextView = (TextView) findViewById(R.id.debug_text_view); playerStateTextView = (TextView) findViewById(R.id.player_state_view); subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles); mediaController = new KeyCompatibleMediaController(this); mediaController.setAnchorView(root); retryButton = (Button) findViewById(R.id.retry_button); retryButton.setOnClickListener(this); videoButton = (Button) findViewById(R.id.video_controls); audioButton = (Button) findViewById(R.id.audio_controls); textButton = (Button) findViewById(R.id.text_controls); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) { CookieHandler.setDefault(defaultCookieManager); } audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this); audioCapabilitiesReceiver.register(); }
private void bindView(FrameLayout oldRoot) { @SuppressLint("InflateParams") ViewGroup root = (ViewGroup) activity.getLayoutInflater().inflate(R.layout.player_view_layout, null); ViewGroupUtils.replaceView(oldRoot, root); root.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { toggleControlsVisibility(); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { view.performClick(); } return true; } }); root.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { return false; } return mediaController.dispatchKeyEvent(event); } }); audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(activity.getApplicationContext(), this); shutterView = root.findViewById(R.id.shutter); videoFrame = (AspectRatioFrameLayout) root.findViewById(R.id.video_frame); surfaceView = (SurfaceView) root.findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); subtitleLayout = (SubtitleLayout) root.findViewById(R.id.subtitles); mediaController = new VideoControllerView(activity, false); mediaController.setAnchorView(root); CookieHandler currentHandler = CookieHandler.getDefault(); if (currentHandler != defaultCookieManager) { CookieHandler.setDefault(defaultCookieManager); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAudioCapabilitiesReceiver = new AudioCapabilitiesReceiver(getActivity(), mAudioCapabilitiesListener); }