private void preparePlayer() { SampleSource sampleSource = new FrameworkSampleSource(this, Uri.parse(mVideo.getContentUrl()), /* headers */ null, RENDERER_COUNT); // Build the track renderers videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT); TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource); // Setup the player player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); // Build the player controls mediaController.setMediaPlayer(new PlayerControl(player)); mediaController.setEnabled(true); player.prepare(videoRenderer, audioRenderer); }
public DemoPlayer(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; //###AXT:: --> try to start the player without internal buffering. We do buffering in Raw Sample sources // player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, -1, -1); //###AXT:: <-- player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<Listener>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; selectedTracks = new int[RENDERER_COUNT]; // Disable text initially. selectedTracks[TYPE_TEXT] = DISABLED_TRACK; }
public DemoPlayer(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; // Enable text initially. player.setSelectedTrack(TYPE_TEXT, TRACK_DEFAULT); }
public VideoPlayer(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; // Disable text initially. player.setSelectedTrack(TYPE_TEXT, TRACK_DISABLED); }
public DemoPlayer(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; // Disable text initially. player.setSelectedTrack(TYPE_TEXT, TRACK_DISABLED); }
private void initPlayer() { player = ExoPlayer.Factory.newInstance(RENDERER_COUNT); playerControl = new PlayerControl(player); if (player != null) { rendererBuilder = getHpLibRendererBuilder(); rendererBuilder.buildRenderers(this); mainHandler.postDelayed(updatePlayer, 200); } }
public ExoPlayerHelper(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; // Disable text initially. player.setSelectedTrack(TYPE_TEXT, TRACK_DISABLED); }
public MediaPlayer(Context context) { this.context = context; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; selectedTracks = new int[RENDERER_COUNT]; // Disable text initially. selectedTracks[TYPE_TEXT] = DISABLED_TRACK; }
private void startBasicPlayback() { player = ExoPlayer.Factory.newInstance(4); player.addListener(this); mediaController.setMediaPlayer(new PlayerControl(player)); mediaController.setEnabled(true); ExtractorSampleSource sampleSource = new ExtractorSampleSource( contentUri, new DefaultUriDataSource(this, Util.getUserAgent(this, "ExoPlayerExtWebMDemo")), new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT, new WebmExtractor(), new FlacExtractor(), new OggExtractor()); TrackRenderer videoRenderer = new LibvpxVideoTrackRenderer(sampleSource, true, handler, this, 50); if (useOpenGL) { player.sendMessage(videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER, vpxVideoSurfaceView); surfaceView.setVisibility(View.GONE); } else { player.sendMessage( videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_SURFACE, surfaceView.getHolder().getSurface()); vpxVideoSurfaceView.setVisibility(View.GONE); } TrackRenderer opusAudioTrackRenderer = new LibopusAudioTrackRenderer(sampleSource); TrackRenderer flacAudioTrackRenderer = new LibflacAudioTrackRenderer(sampleSource); TrackRenderer mediaCodecAudioTrackRenderer = new MediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT); player.prepare(videoRenderer, opusAudioTrackRenderer, flacAudioTrackRenderer, mediaCodecAudioTrackRenderer); player.setPlayWhenReady(true); }
public void onRenderersBuilt(TrackRenderer[] renderers) { surfaceView.setVisibility(View.GONE); player = ExoPlayer.Factory.newInstance(renderers.length); player.addListener(this); mediaController.setMediaPlayer(new PlayerControl(player)); mediaController.setEnabled(true); player.sendMessage(renderers[0], LibvpxVideoTrackRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER, vpxVideoSurfaceView); player.prepare(renderers); player.setPlayWhenReady(true); }
public Player(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 2000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; // Disable text initially. player.setSelectedTrack(TYPE_TEXT, TRACK_DISABLED); }
public VideoPlayer(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; selectedTracks = new int[RENDERER_COUNT]; // Disable text initially. selectedTracks[TYPE_TEXT] = DISABLED_TRACK; }
/** * Creates a {@link DemoPlayer} instance. */ public DemoPlayer(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; // Disable text initially. player.setSelectedTrack(TYPE_TEXT, TRACK_DISABLED); }
public DemoPlayer(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<Listener>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; selectedTracks = new int[RENDERER_COUNT]; // Disable text initially. selectedTracks[TYPE_TEXT] = DISABLED_TRACK; }
private void preparePlayer() { Log.d(TAG, "preparePlayer()"); SampleSource sampleSource = new FrameworkSampleSource(this, Uri.parse(mVideo.getContentUrl()), /* headers */ null, RENDERER_COUNT); // Build the track renderers videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT); TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource); // Setup the player player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); player.prepare(videoRenderer, audioRenderer); if (mIsOnTv) { // This PlayerControl must stay in sync with PlaybackOverlayFragment. // We created methods such as PlaybackOverlayFragment.pressPlay() to request // that the fragment change the playback state. When the fragment receives a playback // request, it updates the UI and then calls a method in this activity according to // PlaybackOverlayFragment.OnPlayPauseClickedListener. playerControl = new PlayerControl(player); } else { // Build the player controls mediaController.setMediaPlayer(new PlayerControl(player)); mediaController.setEnabled(true); } maybeStartPlayback(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); View root = findViewById(R.id.root); mediaController = new MediaController(this); //overscan safe on 1980 * 1080 TV mediaController.setPadding(48, 27, 48, 27); mediaController.setAnchorView(root); shutterView = findViewById(R.id.shutter); surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); SampleSource sampleSource = new FrameworkSampleSource(this, Uri.parse(url), /* headers */ null, RENDERER_COUNT); // Build the track renderers videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT); TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource); // Setup the player player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); // Build the player controls mediaController.setMediaPlayer(new PlayerControl(player)); mediaController.setEnabled(true); player.prepare(videoRenderer, audioRenderer); }
public Player() { eventProxy = new EventProxy(); eventProxy.setPlayer(this); player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; // Disable text initially. player.setSelectedTrack(TYPE_TEXT, TRACK_DISABLED); }
public ExoPlayerWrapper(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; selectedTracks = new int[RENDERER_COUNT]; // Disable text initially. selectedTracks[TYPE_TEXT] = DISABLED_TRACK; }
@Override public void onResume() { super.onResume(); // Setup the player player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); player.seekTo(playerPosition); // Build the player controls mediaController.setMediaPlayer(new PlayerControl(player)); mediaController.setEnabled(true); // Request the renderers callback = new RendererBuilderCallback(); builder.buildRenderers(callback); }
public DemoPlayer(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; selectedTracks = new int[RENDERER_COUNT]; }
public FlyingPlayer(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); lastReportedPlaybackState = STATE_IDLE; rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; // Disable text initially. player.setSelectedTrack(TYPE_TEXT, TRACK_DISABLED); }
public OkPlayer(RendererBuilder rendererBuilder) { this.rendererBuilder = rendererBuilder; player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1500, 5000); player.addListener(this); playerControl = new PlayerControl(player); mainHandler = new Handler(); listeners = new CopyOnWriteArrayList<>(); //初始化播放器状态 lastReportedPlaybackState = ExoPlayer.STATE_IDLE; //初始化渲染器状态 rendererBuildingState = RENDERER_BUILDING_STATE_IDLE; //初始化时禁用字幕渲染器的轨道 player.setSelectedTrack(TYPE_TEXT, TRACK_DISABLED); }