22 Comments

  1. Nite

    Hi,
    I have problems with playing mp4 video when switch to fullscreen/normal, start buffering and play video from start. For mp4 video i use ExtractorMediaSource.

    Thanks

  2. subhanjan

    working if the player is in main activity. But when I place this code and use the exoplayer in another activity I get the error cannot change view. for custom activity, what code should I use?

    • Geoff Ledak

      It should work the same regardless if you’re working with the launcher activity or not.

      Can you post your code somewhere, or the specific error messages you’re getting?

  3. Mansi

    Thanks for a great working example.
    I was able to implement this and it work flawlessly for the most part but I see a little bit of a lag when switching from fullscreen mode to small screen mode and vice versa.
    The only glaring difference between my code and yours is the I’m using ExtractorMediaSource for an mp4 file.
    Any pointers on how I can avoid the lag/latency? Thanks!

    • Geoff Ledak

      Hey Mansi,

      I haven’t tried using an ExtractorMediaSource but I’ll try it tonight. What kind of phone are using? Does it lag when running on an emulator?

      -Geoff

      • Mansi

        I’m actually using it on a FireTV device. It lags on both the emulator and the TV itself.
        There’s, maybe, half a second delay before the video continues to play – its not seamless.

        • Mansi

          And the interesting part is: there is no lag in audio. The lag is only seen in video. So while the audio continues to play, the video is stuck for half a second before it catches up with the audio!

  4. Leonard

    Hi, Geoff,

    This is a great solution, however, it seems only works under same screen orientation? Could you share some opinion to implement the full screen like youtube does?

    • Geoff Ledak

      Hey Leonard,

      Device rotation will work with this solution.

      If you wanted to force the app into landscape mode when the video is set to fullscreen like the youtube app does, I believe you could add setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); inside the openFullscreenDialog() method and setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); inside the closeFullscreenDialog() method.

      Cheers!

      -Geoff

  5. JRB

    Hey Geoff,

    You are a Life saver bud, thanks for the tutorial. Also I wanted to know if we can add Variable speed playback options to the same tutorial. Can you give it a look? Also, there is a small lag in the video when changing the orientation from Portrait to Landscape or from Landscape to Portrait.

  6. Darian

    Geoff, your tutorial works when the activity starts on portrait but when the activity starts on landscape and try to exit full screen the app stop woking. Any suggestions???

  7. mitesh viradiya

    Hello,

    I would like to say thank you very much for such a good solution with example. its too much help full for me.

    I have one problem, I am using your method for full screen functionality and its work fine but when I use my custom control for exoplayer (i.e. app:controller_layout_id=”@layout/exoplayer_controls”) i use it for achieving thumbnail image when timebar event done by the user.

    Here it work fine while in normal screen but while i start full screen dialog than change the video position it dose not load the image even method was called for thumbnail

  8. hiddeneyes02

    Thank you for the great tutorial

    One point though: PlaybackControlView controlView = mExoPlayerView.findViewById(R.id.exo_controller);

    This is depreacated, I used findViewById directly on your my SimpleExoPlayerView

  9. Mathi

    When switching from small screen to fullscreen the video stucks for some time and then resumes. How can i make the transition smooth.

  10. Abhishek Kumar

    This only works for one orientation mode. How can I open the dialog in landscape mode when fullscreen button is clicked?

    The above way is very good when you want both your half screen exoplayer and fullscreen exoplayer in the same orientation. Any way we can go with this approach for changing the orientation?

    • Geoff Ledak

      Hi Abhishek,

      I haven’t tried it, but if you want to force the app into landscape mode when the video is set to fullscreen, I believe you could add setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); inside the openFullscreenDialog() method and setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); inside the closeFullscreenDialog() method.

      -Geoff

  11. strike back

    Nice programming style 🙂
    Solved a few of my problems, namely:
    1) of course the fullscreen thing…
    2)adding custom layout elements to my Exoplayer (2 buttons)
    to be able to speed up/slow down the playback by hitting them.
    so thanks!
    Best regards, Lukas

Leave a Reply

Your email address will not be published. Required fields are marked *