Handling application interrupts during playback handling-application-interrupts-during-playback

Playback in a media application can be interrupted in a variety of ways. For example, a user can explicitly press pause, or a user can put the application into the background. Regardless of what causes an interruption in media playback, the tracking instructions are the same.

  1. Call trackPause when the application is interrupted (goes to background, media pauses, etc.).
  2. Call trackPlay when the application returns to the foreground and/or the media resumes playing.
NOTE
The Media Analytics team has seen instances where customers called trackSessionStart when their app returned from the background. Doing so results in the playback up to that point not counting towards the total playback time, along with losing earlier progress markers, segments, and so on. Instead, call trackPlay when the app returns and/or the media resumes playing.

FAQ about handling application interrupts: faq-about-handling-application-interrupts

  • How long should an app be backgrounded before the session closes?

    If the application allows background playback, it can continue tracking by calling our APIs and we will send all our regular tracking pings. Not many video apps allow background playback except for YouTube Red, however, all audio apps allow this. If the application does not allow background playback, then it is advisable to stay in the Pause State for one minute, and then end the tracking session. The application cannot continue sending Pause pings, because in most cases it cannot determine if the user is going to return to continue viewing the media, or determine when it is going to be killed. It is also a bad experience to keep sending pings when in the background.

  • What is the correct way to handle re-starting tracking after the app has been in the background for a long time?

    The application should call trackSessionEnd to end the tracking session. From Version 2.1, the SDK sends an “end” ping to notify the back-end that the tracking session is closed.

  • What about restarting the same session?

    For information about resuming a tracking session, see Resuming inactive sessions.The SDK sends a resume ping to notify the back-end that the user is manually resuming the session.

recommendation-more-help
c8eee520-cef5-4f8c-a38a-d4952cfae4eb