This website or its third-party tools use cookies which are necessary to its functioning and required to improve your experience. By clicking the consent button, you agree to allow the site to use, collect and/or store cookies.
Please click the consent button to view this website.
I accept
Deny cookies Go Back

Mobile app tutorials

  • Home
  • About
  • Contact
  • Login
You are here: Home / Kotlin Camera2 API / Kotlin Camera2 video picture in picture

December 13, 2017 by nigel

Kotlin Camera2 video picture in picture




The Kotlin Camera2 video picture in picture Android development tutorial describes how to add Android 8.0 picture in picture support for video playback.

This Kotlin on Android development tutorial follows on from the Kotlin camera2 ExoPlayer tutorial.

In this Kotlin on Android tutorial we will cover:

  • Registering for PIP support
  • Adding additional variables to the ViewModel
  • Adding video playback state machine
  • Adding to video listener to ExoPlayer
  • Getting width & height of ExoPlayer video
  • Setting aspect ratio for PIP params
  • Calling PIP mode

Episodes

  1. Icons
  2. MediaRecorder
  3. Rear Camera Record
  4. Round preview thumbnail
  5. Sharing Uri with ViewModel
  6. Video Playback with ExoPlayer
  7. Video PIP
  8. Front Camera Record (Premium)
  9. Video Record with Audio (Premium)
  10. Replace TextureView with SurfaceView (Premium)

Disclaimer, it is recommended to follow this Kotlin on Android tutorial series using a Google Pixel or Nexus device.
Please do not try it with the Android Emulator. Bugs have also been observed in camera stacks of none Google devices, which may be exposed by this tutorial series.


To get access to the source code and code descriptions please fill out the form below to complete your free membership:
An account with your username and/or email address has been created. Log in here to access your products or complete a purchase. [Note: an account will be created even if your initial transaction failed at checkout. If this happened to you, simply log in and attempt your transaction again.]






Conclusion

In the Kotlin Camera2 video picture in picture Android development tutorial, we described how to implement PIP mode for during the fragment video playback.

Android PIP mode had to be added to main activity in the Android manifest file. Then the onUserLeaveHint() method can be implemented inside the Android activity. The onUserLeaveHint() method will be called when the user selects the home button during the video playback.

A flag was used to monitor video playback state. With Android PIP mode made only available during video playback.
The Android ViewModel was used to pass the video playback status from the ExoPlayerFragment to the main Android activity.

The Exoplayer video aspect ratio was also passed via the Android ViewModel to be used for the PIP parameters.

The following Kotlin tutorial will describe how to switch between front and rear-facing cameras.

Print Friendly

Filed Under: Kotlin Camera2 API

  • Facebook
  • Google+
  • Twitter
  • YouTube




Recent Forum Topics

  • Kotlin Fragments
  • Kotlin Camera2 API
  • HTTP Image Libraries

Recent Posts

  • Installing and running flutter
  • Kotlin Camera2 API MediaRecorder
  • Flutter IntelliJ Tips for Beginners
  • Migrating Fragments to Jetpack Navigation
  • Flutter TabBar

Recent Posts

  • Installing and running flutter
  • Kotlin Camera2 API MediaRecorder
  • Flutter IntelliJ Tips for Beginners
  • Migrating Fragments to Jetpack Navigation
  • Flutter TabBar

Search Form

  • Facebook
  • GitHub
  • Google+
  • Twitter
  • YouTube

© 2021 - WWW.MOBAPPTUTS.COM