Java 类com.google.android.exoplayer2.ui.PlaybackControlView 实例源码

项目:react-native-exoplayer-intent-video    文件:PlayerView.java   
public PlayerView(Context context, SimpleExoPlayer player) {
    super(context);
    simpleExoPlayerView = new SimpleExoPlayerView(context);
    progressBar = new ProgressBar(context);
    textView = new TextView(context);
    textView.setX(40);
    textView.setY(20);
    textView.setTextColor(Color.parseColor("#FFFFFF"));
    textView.setTextSize(16);
    textView.setText("By Herudi");
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(100,100);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    simpleExoPlayerView.setLayoutParams(new SimpleExoPlayerView.LayoutParams(
            SimpleExoPlayerView.LayoutParams.MATCH_PARENT,
            SimpleExoPlayerView.LayoutParams.MATCH_PARENT
    ));
    setLayoutParams(new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT
    ));
    setBackgroundColor(ContextCompat.getColor(context, android.R.color.black));
    addView(simpleExoPlayerView);
    addView(textView);
    addView(progressBar,params);
    simpleExoPlayerView.setUseController(true);
    simpleExoPlayerView.requestFocus();
    simpleExoPlayerView.setPlayer(player);
    simpleExoPlayerView.setControllerVisibilityListener(new PlaybackControlView.VisibilityListener() {
        @Override
        public void onVisibilityChange(int visibility) {
            if (visibility==0){
                textView.setVisibility(VISIBLE);
            }else {
                textView.setVisibility(GONE);
            }
        }
    });
}
项目:zapp    文件:MediathekPlayerActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_mediathek_player);
    ButterKnife.bind(this);

    // set to show
    //noinspection ConstantConditions
    show = (MediathekShow) getIntent().getExtras().getSerializable(EXTRA_SHOW);
    if (show == null) {
        Toast.makeText(this, R.string.error_mediathek_called_without_show, Toast.LENGTH_LONG).show();
        finish();
        return;
    }

    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setTitle(show.getTopic());
        getSupportActionBar().setSubtitle(show.getTitle());
    }


    player = new Player(this, show, this, this);
    player.setView(videoView);
    updateSubtitleButtons();

    videoView.setControllerVisibilityListener(this);
    videoView.requestFocus();
    controlView = (PlaybackControlView) videoView.getChildAt(1);
}
项目:Cluttr    文件:VideoActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);
    ButterKnife.bind(this);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

    path = getIntent().getExtras().getString("MEDIA_URI");

    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

    TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(null);
    TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
    LoadControl loadControl = new DefaultLoadControl();

    player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);

    playerView.setPlayer(player);

    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "org.polaric.cluttr"), null);
    ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
    MediaSource videoSource = new ExtractorMediaSource(Uri.parse(path), dataSourceFactory, extractorsFactory, null, null);

    player.prepare(videoSource);

    playerView.setControllerVisibilityListener(new PlaybackControlView.VisibilityListener() {
        @Override
        public void onVisibilityChange(int visibility) {
            if  (visibility==View.VISIBLE) {
                fab.show();
            } else {
                fab.hide();
            }
        }
    });
}
项目:Android-O-Feature    文件:PictureInPictureActivity.java   
private PlaybackControlView.VisibilityListener onControllerVisibilityChanges() {
    return visibility -> btnPictureInPicture.setVisibility(visibility);
}
项目:zapp    文件:Player.java   
public void rewind() {
    player.seekTo(
        Math.max(player.getCurrentPosition() - PlaybackControlView.DEFAULT_REWIND_MS, 0)
    );
}
项目:zapp    文件:Player.java   
public void fastForward() {
    player.seekTo(
        Math.min(player.getCurrentPosition() + PlaybackControlView.DEFAULT_FAST_FORWARD_MS, player.getDuration())
    );
}
项目:ExoPlayerVideoView    文件:ExoVideoView.java   
@SuppressWarnings("WrongConstant")
    public ExoVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        boolean useTextureView = false;
        @SuperAspectRatioFrameLayout.ResizeMode
        int resizeMode = SuperAspectRatioFrameLayout.RESIZE_MODE_FIT;

        boolean portrait = true;

        int rewindMs = PlaybackControlView.DEFAULT_REWIND_MS;
        int fastForwardMs = ExoVideoPlaybackControlView.DEFAULT_FAST_FORWARD_MS;
        int controllerShowTimeoutMs = ExoVideoPlaybackControlView.DEFAULT_SHOW_TIMEOUT_MS;

        float textSize = Float.MIN_VALUE;

        if (attrs != null) {
            TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs,
                    R.styleable.ExoVideoView, 0, 0);

            try {
                useController = typedArray.getBoolean(R.styleable.ExoVideoView_useController, useController);
                useTextureView = typedArray.getBoolean(R.styleable.ExoVideoView_useTextureView, false);
                resizeMode = typedArray.getInt(R.styleable.ExoVideoView_resizeMode, SuperAspectRatioFrameLayout.RESIZE_MODE_FIT);
                rewindMs = typedArray.getInt(R.styleable.ExoVideoView_rewindIncrement, rewindMs);
                fastForwardMs = typedArray.getInt(R.styleable.ExoVideoView_fastForwardIncrement, fastForwardMs);
                controllerShowTimeoutMs = typedArray.getInt(R.styleable.ExoVideoView_showTimeout, controllerShowTimeoutMs);
                portrait = typedArray.getBoolean(R.styleable.ExoVideoView_isPortrait, true);
                textSize = typedArray.getDimension(R.styleable.ExoVideoView_topWrapperTextSize, Float.MIN_VALUE);
            } finally {
                typedArray.recycle();
            }
        }



        LayoutInflater.from(getContext()).inflate(R.layout.exo_video_view, this);

        componentListener = new ComponentListener();

        layout =  findViewById(R.id.videoFrame);
        layout.setResizeMode(resizeMode);

        frameCover =  findViewById(R.id.frameCover);

        shutterView = findViewById(R.id.shutter);

        subtitleLayout =  findViewById(R.id.subtitles);
        subtitleLayout.setUserDefaultStyle();
        subtitleLayout.setUserDefaultTextSize();


        controller =  findViewById(R.id.control);
        controller.setTopWrapperTextSize(textSize);
        controller.setPortrait(portrait);
        controller.hide();
        controller.setRewindIncrementMs(rewindMs);
        controller.setFastForwardIncrementMs(fastForwardMs);
        this.controllerShowTimeoutMs = controllerShowTimeoutMs;

        View view = useTextureView ? new TextureView(context) : new SurfaceView(context);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        view.setLayoutParams(params);
        surfaceView = view;
        layout.addView(surfaceView, 0);

        audioManager =  (AudioManager) context.getApplicationContext().getSystemService(AUDIO_SERVICE);

//        this.controllerShowTimeoutMs = controllerShowTimeoutMs;


    }
项目:yjPlay    文件:BaseView.java   
/****
 * 获取控制类
 *
 * @return PlaybackControlView playback control view
 */
@Nullable
public PlaybackControlView getPlaybackControlView() {
    return playerView != null ? playerView.getControllerView() : null;
}