Live Channels Has Hidden Support for Pausing, Time Shifting

Live Channels is an app made by Google which allows third-party developers to create their own input services. This can be done using Google’s TvInputFramework, and simplified further with my open source library.

Live Channels Guide

This triage of channels works fairly well at providing users an ample amount of high-quality content. However, users have continued to look for more features in the app, one of the biggest of which is the ability to pause and resume playback. A normal cable box and DVR gives users the ability to pause live TV or even skip backward if they missed something. If you have to run a short errand after a few minutes, you want the stream to stop at its current position until you return.

Although there do not appear to be any apps that will give this functionality currently, after looking through the APIs of Live Channels, this functionality does appear to be supported. A supported app will add a third row of options, above the channel guide, called Playback Controls.

You can pause/play, skip, or rewind at speeds between 2-5x.

In the TvInputService.Session class, there are a number of methods relating to time shifting. For a service to implement this,

notifyTimeShiftStatusChanged(TvInputManager.TIME_SHIFT_STATUS_AVAILABLE)

must be called. From there, a number of methods can be overridden.

Pausing/Playing

public void onTimeShiftPause ()
public void onTimeShiftResume()

These two methods, when overriden, will provide logic for when your media is going to be stopped and resumed.

Seeking

Users will likely also want to go back and forth through the stream, perhaps catching up to realtime or trying to rewatch a certain point. There are a few methods to override here that give a look at what will be possible.

public long onTimeShiftGetStartPosition()
public long onTimeShiftGetCurrentPosition()
public void onTimeShiftSeekTo(long timeMs)

The user can seek to any position in the channel between the beginning and current positions, which are controlled by the third-party app. If the program changes, perhaps the start position will change as well.

The method

public void onTimeShiftSetPlaybackParams(PlaybackParams params)

also is available, which changes when the playback speed changes (ie. rewinding).

Conclusion

This functionality was just added in Android 6.0, Marshmallow, so it won’t be available to most devices right now. Additionally, apps will have to implement this individually. By default time shifting is not available, and there is no system wide ability. will be updated soon to add support time shifting. For app developers who’ve made their own service, they may want to look into these APIs and try implementing them.

It is possible that Android N includes DVR functionality in Live Channels. Now that the media playback controls have been implemented, adding the ability to record live channels and play them back later seems more possible than before. The documentation hints that some sort of recording will be in place.

public long onTimeShiftGetStartPosition ()

Added in API level 23
Returns the start playback position for time shifting, in milliseconds since the epoch. Returns TIME_SHIFT_INVALID_TIME if the position is unknown at the moment.

The start playback position of the time shifted program should be adjusted when the implementation cannot retain the whole recorded program due to some reason (e.g. limitation on storage space). It is the earliest possible time position that the user can seek to, thus failure to notifying its change immediately might result in bad experience where the application allows the user to seek to an invalid time position.

Nick Felker

Nick Felker is a student Electrical & Computer Engineering student at Rowan University (C/O 2017) and the student IEEE webmaster. When he's not studying, he is a software developer for the web and Android (Felker Tech). He has several open source projects on GitHub Devices: Moto G-2013 Moto G-2015, Moto 360, Google ADT-1, Nexus 7-2013 (x2), Lenovo Laptop, Custom Desktop. Although he was an intern at Google, the content of this blog is entirely independent and his own thoughts.

More Posts - Website

Follow Me: