Is Android Picture-In-Picture Next Step to Innovation For The Edtech Industry?

When you look at it for the first time, the Android PIP feature looks pretty dope. It is a classic example of taking ‘ease of use’ into account in the design process.

For me, the fact that you can play Youtube and still use everything else on phone was enough to rejoice. The feature alters your video watching experience and how. It lets you do so many things without obstructing with your audio/video experience.

PIP is not like split screen where you work on two exclusive apps, it’s a special multi-window mode that allows video playback in a small screen on the edge while users can navigate between rest of the apps.

Hey, we were doing fine before this happened

So, around the same time, one of our clients in the Edtech industry came up with an unusual request. They wanted to provide their users with editable notes which can be accessed while watching the video lectures. Their current process required the users to switch frequently between the apps and, let’s just say, it was not as fancy as it sounds.

The course is too much and there’s an issue, it’s not okay

As much as reasonable the problem was, the solution was not easy. We knew the PIP feature was godsent for this, but it was used by a few popular apps only. We talked to the client about it and they were pretty excited. In fact, the client said that if this works out, they will scale it up and add notes for all the sessions. Their users have asked for the same quite often and PIP might just be the answer to everything.

We researched around the feature and it was one of the projects where things looked easy from far. Excited and scared, we went ahead and planned the development process. It was about to be a fun ride, or so we hoped!

Hey, can you tell your friends we need it sooner

We began with the project and planned sprints. This was going to be one of those projects where things either worked or they tanked, no in-betweens. Even though Android launched a complete guide on how you can include the feature in your app, significant things had to be planned. The app’s primary service was to provide the lectures and under no circumstance, the efficiency of the same could be compromised.

And I hope it’s gonna be fine and working again

We started stepping up the ladder with basic functions including:

Declaring PIP Support: The system does not automatically support PIP for apps. We had to register the video activity by setting android:supportsPictureInPicture and android:resizeableActivity to true. We had to also include room for layout changes in the code so that the activity doesn’t relaunch when layout changes happen in PIP transitions.

Switching Activities: To enter the PIP mode we called a function enterPictureInPictureMode() and further added a logic that switches an activity into PIP mode instead of running in the background.

UI during PIP Mode: When the function enters the PIP mode the system calls Activity.onPictureInPictureModeChanged() or Fragment.onPictureInPictureModeChanged(). We overrode these callbacks to redraw the UI elements in the activity.

Adding these basic functions got the PIP mode running. The client was not completely sure and hence, went ahead with initial testing. The application worked fine, at least prima facie. But there was a small problem. When the users tapped the back button to switch to the app from the pinned video, the app unexpectedly closed. In short, the user couldn’t restore the app.

So can we pull over and get rid of this once and for ever

It took a while for us to figure this out. The thing is, when you switch to the PIP mode, Android moves only the PIP activity into a new task. This causes a problem if the user stays within the app after restoring the PIP window back to full screen and tapping back. The app must re-create the back-stack to accomplish this.

We understood what was happening within the whole process and why the user can’t restore the app. Due to application’s current architecture, back-stack recreation was happening automatically. To resolve the problem we went through many tests to find out where we were losing the back-stack process. This was our gateway. We added a link after the notes which redirected the student to the video.

Another problem popped up when we were at our final stages of testing. The video playback in the PIP mode was causing audio intervention for other apps. To manage the video playback and other apps, we called a function requestAudioFocus() and supplied a parameter AudioFocusRequest. Further, we used this parameter to request and abandon focus.

Within the span of five weeks we solved the problem and successfully implemented the software which helped the client get more students onboard.


Key Takeaways (feel free to use and learn):

> PIP is intended for applications and actions that play full-screen videos. So you should avoid anything except video content when switching your activity into PIP mode.
> As the PIP window is a floating screen, make it a point to avoid showing critical information on the areas that can be obscured by the PIP Window.
> When your app is in PIP mode, video playback in the PIP window can cause audio interference with another app, such as a music player app or voice search app. To avoid this, request audio focus when you start playing the video, and handle audio focus change notifications, as described in Managing Audio Focus.
> PIP only works in Android Oreo 8.0 and versions above.

Quickly make a move to upgrade your mobile applications. Get in touch with our development team and give your users an astonishing experience of learning.


Stay up to date with latest happenings in our space