Sunday, May 17, 2020

Is there any way to activate picture-in-picture mode for the Disney hotstar app for Android?


Woman In Black Tank Top Using Laptop

You’re in the middle of watching some engaging content on Hotstar, your best friend sends you a text, if you switch, your video pauses, if you don’t you’re a bad friend! Now, you don’t have to make these choices anymore!

With our latest release (v7.2.0), we are introducing Picture-in-Picture mode on the Hotstar Android app for our premium customers.

What is it?

Starting with Android Oreo, Android launched a new feature called Picture-in-Picture support. This allows any activity to be launched in PIP mode. PIP is a special type of multi-window mode mostly used for video playback. It lets the user watch a video in a small window pinned to a corner of the screen while navigating between apps or browsing content on the main screen.

Person Using Macbook Pro on White Table

Why only Premium?

Given the form factor of the playback window, we wanted to ensure that our customers had the best experience. Our premium subscription is an ad free experience, and as such, is well suited to our original goal of adding this experience. Now, you have yet another reason to go get that premium subscription!

Technical Challenges

Handling Task

Problem: Ideally, the Watch screen should have a single task instance, that is, one Activity to handle new watch requests. If the user has triggered the Watch screen for a movie content and then she wishes to see another movie, then the new movie play request should be handled by onNewIntent(Intent) call of the WatchPage screen. Due to some technical challenges with the Player, we were not able to handle this scenario. That said, the request for new Watch Page always triggers a new WatchPage pausing the previous player state.

Also, whenever the activity goes in PIP mode, Android creates a new task and puts that activity as the root of the task. So, if you have gone in PIP and pressed the Recents hardware button to see the current tasks, you will find two tasks lying around for the same app.

  1. android:resizeableActivity and android:supportsPictureInPicture are used for launching the activity into PIP mode.
  2. android:excludeFromRecents- Whether or not the task initiated by this activity should be excluded from the list of recently used applications, the overview screen. That is, when this activity is the root activity of a new task, this attribute determines whether the task should not appear in the list of recent apps. Set “" if the task should be excluded from the list; set "" if it should be included. The default value is "".
  3. android:autoRemoveFromRecents- Whether or not tasks launched by activities with this attribute remains in the overview screen until the last activity in the task is completed. If , the task is automatically removed from the overview screen.

Using the attributes defined above helped us remove the PIP task to be shown in recents thus avoiding confusion to the users with multiple tasks for the same application.

Woman in Gray Long Sleeve Shirt Sitting Beside Woman in Blue Long Sleeve Shirt

How to leave PIP?

Problem: So, a video is being played on PIP and you went ahead to open YouTube to watch some movie trailer. What happens next! The expected result would be to close the PIP window and start the YouTube video playing seamlessly. But this was not the case as our PIP window remained stuck hanging around along with YouTube screen in paused state. Not the experience we wanted.

Solution: We started looking out for solutions and got hold of some StackOverflow post too. But it did not help our cause. Note that Android does not provide any API which says  . So we brainstormed further and found a way to exit PIP using AudioFocus event. If you have started a video in PIP mode on Hotstar, and then you went to watch a trailer on YouTube, the app receives AudioFocus change events via AudioManager.OnAudioFocusChangeListener. Now it was all about listening to those events. Whenever any other app tries to play video or audio, it tries to capture AudioFocus and the change of that event is triggered. We now knew that an AudioFocus change had happened and Hotstar was in PIP mode, then it was safer to close the PIP task and thus the long host problem of exiting PIP mode was solved.

Why PIP?

Consider some regular use cases.

  1. You are watching Game of Thrones on Hotstar and suddenly your friend pings you to join for an evening get together.
  2. You are binge watching The Wire on Hotstar and you want to order some food.

In all such cases, you do not want your watch experience to be taken away. That is, ordering food or talking to a friend should not stop you from playing video. Now this won’t happen anymore. Being in PIP, you can still do any task that you would like to do while still watching your favorite shows or movies on Hot star

The PIP feature adds a lot of value to the User Experience we want to give. It takes the video watching experience to a whole new level by not holding the users back to perform other actions. We are excited to bring this to you and would love to know your experiences. Share your love on Twitter for any kind of feedback. Yes, WE ARE LISTENING!

Author Image
AboutTechnical Support

Soratemplates is a blogger resources site is a provider of high quality blogger template with premium looking layout and robust design

No comments:

Post a Comment