14 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???

Leave a Reply

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