com.google.android.exoplayer.AspectRatioFrameLayout Java Examples

The following examples show how to use com.google.android.exoplayer.AspectRatioFrameLayout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExSimpleVpFragment.java    From ExVidPlayer with Apache License 2.0 5 votes vote down vote up
private void initViews() {
  progressBar = (ProgressBar) mView.findViewById(R.id.pbar);
  surfaceView = (SurfaceView) mView.findViewById(R.id.surface_view);
  //skiptexts
  prgCenterText = (LinearLayout) mView.findViewById(R.id.seekbar_center_text);
  tvCenterCurrent = (TextView) mView.findViewById(R.id.txt_seek_currTime);
  tvCenterProg = (TextView) mView.findViewById(R.id.txt_seek_secs);
  //brightness
  /*brightnessSlider = (LinearLayout) getView(R.id.brightness_slider_container);
  ivBrightness = (ImageView) getView(R.id.brightness_image);
  ivBrightnessImage = (ImageView) getView(R.id.brightnessIcon);
  pBarBrighness = (ProgressBar) getView(R.id.brightness_slider);
  tvBrightnessPercent = (TextView) getView(R.id.brigtness_perc_center_text);
  brightnessCenterText = (LinearLayout) getView(R.id.brightness_center_text);
  //volume
  volumeSlider = (LinearLayout) getView(R.id.volume_slider_container);
  ivVolume = (ImageView) getView(R.id.vol_image);
  ivVolumeImage = (ImageView) getView(R.id.volIcon);
  pBarVolume = (VolBar) getView(R.id.volume_slider);
  tvVolumePercent = (TextView) getView(R.id.vol_perc_center_text);
  volumeCenterText = (LinearLayout) getView(R.id.vol_center_text);*/

  aspectRatioFrameLayout=(AspectRatioFrameLayout)getView(R.id.video_frame);
  rlReplay = (RelativeLayout) getView(R.id.rlReplay);
  ivReplay = (ImageView) getView(R.id.replayEvent);
  ivReplay.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View view) {
      rlReplay.setVisibility(View.GONE);
      if (exVidPlayer != null) {
        exVidPlayer.seekTo(0);
        exVidPlayer.play();
      }
    }
  });
}
 
Example #2
Source File: ExVpCompleteFragment.java    From ExVidPlayer with Apache License 2.0 5 votes vote down vote up
private void initViews() {
  progressBar = (ProgressBar) mView.findViewById(R.id.pbar);
  surfaceView = (SurfaceView) mView.findViewById(R.id.surface_view);
  //controls
  root = (LinearLayout) mView.findViewById(R.id.root);
  ivLock = (ImageButton) mView.findViewById(R.id.btn_lock);
  ivRev = (ImageButton) mView.findViewById(R.id.btn_rev);
  ivForword = (ImageButton) mView.findViewById(R.id.btn_fwd);
  ivNext = (ImageButton) mView.findViewById(R.id.btn_next);
  ivPrev = (ImageButton) mView.findViewById(R.id.btn_prev);
  ivPlayPause = (ImageButton) mView.findViewById(R.id.btn_pause);
  ivSetting = (ImageButton) mView.findViewById(R.id.btn_settings);
  mProgress = (SeekBar) mView.findViewById(R.id.seekbar);
  tvCurrent = (TextView) mView.findViewById(R.id.txt_currentTime);
  tvTotal = (TextView) mView.findViewById(R.id.txt_totalDuration);
  prgCenterText = (LinearLayout) mView.findViewById(R.id.seekbar_center_text);
  tvCenterCurrent = (TextView) mView.findViewById(R.id.txt_seek_currTime);
  tvCenterProg = (TextView) mView.findViewById(R.id.txt_seek_secs);
  //brightness
  brightnessSlider = (LinearLayout) getView(R.id.brightness_slider_container);
  ivBrightness = (ImageView) getView(R.id.brightness_image);
  ivBrightnessImage = (ImageView) getView(R.id.brightnessIcon);
  pBarBrighness = (ProgressBar) getView(R.id.brightness_slider);
  tvBrightnessPercent = (TextView) getView(R.id.brigtness_perc_center_text);
  brightnessCenterText = (LinearLayout) getView(R.id.brightness_center_text);
  //volume
  volumeSlider = (LinearLayout) getView(R.id.volume_slider_container);
  ivVolume = (ImageView) getView(R.id.vol_image);
  ivVolumeImage = (ImageView) getView(R.id.volIcon);
  pBarVolume = (VolBar) getView(R.id.volume_slider);
  tvVolumePercent = (TextView) getView(R.id.vol_perc_center_text);
  volumeCenterText = (LinearLayout) getView(R.id.vol_center_text);

  aspectRatioFrameLayout=(AspectRatioFrameLayout)getView(R.id.video_frame);
}
 
Example #3
Source File: ExVpFragment.java    From ExVidPlayer with Apache License 2.0 5 votes vote down vote up
private void initViews() {
  progressBar = (ProgressBar) mView.findViewById(R.id.pbar);
  surfaceView = (SurfaceView) mView.findViewById(R.id.surface_view);
  //skiptexts
  prgCenterText = (LinearLayout) mView.findViewById(R.id.seekbar_center_text);
  tvCenterCurrent = (TextView) mView.findViewById(R.id.txt_seek_currTime);
  tvCenterProg = (TextView) mView.findViewById(R.id.txt_seek_secs);
  //brightness
  brightnessSlider = (LinearLayout) getView(R.id.brightness_slider_container);
  ivBrightness = (ImageView) getView(R.id.brightness_image);
  ivBrightnessImage = (ImageView) getView(R.id.brightnessIcon);
  pBarBrighness = (ProgressBar) getView(R.id.brightness_slider);
  tvBrightnessPercent = (TextView) getView(R.id.brigtness_perc_center_text);
  brightnessCenterText = (LinearLayout) getView(R.id.brightness_center_text);
  //volume
  volumeSlider = (LinearLayout) getView(R.id.volume_slider_container);
  ivVolume = (ImageView) getView(R.id.vol_image);
  ivVolumeImage = (ImageView) getView(R.id.volIcon);
  pBarVolume = (VolBar) getView(R.id.volume_slider);
  tvVolumePercent = (TextView) getView(R.id.vol_perc_center_text);
  volumeCenterText = (LinearLayout) getView(R.id.vol_center_text);

  aspectRatioFrameLayout = (AspectRatioFrameLayout) getView(R.id.video_frame);

  rlReplay = (RelativeLayout) getView(R.id.rlReplay);
  ivReplay = (ImageView) getView(R.id.replayEvent);
  ivReplay.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View view) {
      rlReplay.setVisibility(View.GONE);
      if (exVidPlayer != null) {
        exVidPlayer.seekTo(0);
        exVidPlayer.play();
      }
    }
  });
}
 
Example #4
Source File: ExVidPlayerImp.java    From ExVidPlayer with Apache License 2.0 5 votes vote down vote up
public ExVidPlayerImp(Activity activity, SurfaceView surface, Handler handler,
    AspectRatioFrameLayout aspectRatioFrameLayout) {
  this.activity = activity;
  this.surface = surface;
  this.aspectRatioFrameLayout = aspectRatioFrameLayout;
  this.mainHandler = handler;
}
 
Example #5
Source File: VideoPlayerActivity.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #6
Source File: VideoPlayerActivity.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #7
Source File: ExVidPlayer.java    From ExVidPlayer with Apache License 2.0 4 votes vote down vote up
public static ExVidPlayerImp newInstance(Activity actvity, SurfaceView surface, Handler handler,
    AspectRatioFrameLayout aspectRatioFrameLayout) {
  return new ExVidPlayerImp(actvity, surface, handler, aspectRatioFrameLayout);
}
 
Example #8
Source File: PlayerActivity.java    From Android-Example-HLS-ExoPlayer with Apache License 2.0 4 votes vote down vote up
@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();
}
 
Example #9
Source File: VideoPlayerView.java    From iview-android-tv with MIT License 4 votes vote down vote up
public VideoPlayerView(Context context, PlaybackControls controller, View root) {
    mContext = context;
    mediaController = controller;
    shutterView = root.findViewById(R.id.shutter);
    videoFrame = (AspectRatioFrameLayout) root.findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) root.findViewById(R.id.surface_view);
    debugTextView = (TextView) root.findViewById(R.id.debug_text_view);
    debugView = root.findViewById(R.id.debug_view);
    statusTextView = (TextView) root.findViewById(R.id.status);
    playerStateTextView = (TextView) root.findViewById(R.id.player_state_view);
    subtitleLayout = (SubtitleLayout) root.findViewById(R.id.subtitles);
    nextEpisodeCard = root.findViewById(R.id.next_episode_card);
    episodeDetails = root.findViewById(R.id.episode_details);
    episodeTitle = (TextView) root.findViewById(R.id.episode_title);
    seriesTitle = (TextView) root.findViewById(R.id.series_title);
    duration = (TextView) root.findViewById(R.id.duration);

    ImageCardView card = (ImageCardView) root.findViewById(R.id.next_episode);
    card.setFocusable(true);
    card.setFocusableInTouchMode(true);
    card.setInfoVisibility(View.VISIBLE);
    card.setExtraVisibility(View.VISIBLE);
    card.setInfoAreaBackgroundColor(context.getResources().getColor(R.color.black_900));
    Point size = new Point(context.getResources().getDimensionPixelSize(R.dimen.card_width),
            context.getResources().getDimensionPixelSize(R.dimen.card_height));
    nextEpisode = new EpisodeCardView(context, card, size, false);
    nextEpisode.getImageCardView().setCardType(BaseCardView.CARD_TYPE_INFO_OVER);

    debugView.setVisibility(View.GONE);

    root.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return handleTouchEvents(view, motionEvent);
        }
    });
    root.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            return handleKeyEvents(v, keyCode, event);
        }
    });
}