ExoPlayer
ExoPlayer copied to clipboard
OfflineLicenseHelper get remaining license duration
Hello,
We are using ExoPlayer 2.14.2 but this question is valid for all versions.
The OfflineLicenseHelper.getLicenseDurationRemainingSec() method returns a Pair of license and playback durations.
The 'license duration' is the duration during the license is valid after the download, for example 30 days. The 'playback duration' is the period of time that the license is valid since the initial playback, for example 48 hours.
I want to display the remaining time before expiration to the user on each content. In a first time the remaining time to display is the 'license duration' but after the first video playback we have use the 'playback duration'.
My question is : How to know if we have to use the 'license duration' or the 'playback duration' without saving a value to know if we have already started to watch the video and without saving the original license durations ?
On some devices like Pixel or OnePlus the 'license duration' is set to Long.MAX_VALUE after the first playback so this is possible to get the right value using the following code
fun OfflineLicenseHelper.getMinLicenseDuration(keySetId: ByteArray): Long { val pair = getLicenseDurationRemainingSec(keySetId) return if (pair.first != Long.MAX_VALUE) pair.first else pair.second }
But this is not working on all devices like Samsung or Huawei that keep the same 'license duration' and just start to count down on the 'playback duration'.
So I was wondering, is there a recommended way to get the license duration if the video was never played and playback duration if it was played at least once ?
@rrfrias This sounds to me like maybe the license is setting license duration and playback duration but not rental duration (similar to [internal b/173059187 and b/186392548]). Does that sound plausible to you?
Can you tell us what your policy values for license and rental duration are? It will be helpful if you can share the make, model, build and widevine version* of the devices you are testing with.
License duration is the minimum of license or rental duration. Apologies if that is confusing. If you have a Widevine partner engineering contact, they should be able to share a document that details these fields.
On some devices like Pixel or OnePlus the 'license duration' is set to Long.MAX_VALUE after the first playback so this is possible to get the right value using the following code
Was it set to a value other than Long.MAX_VALUE before first playback?
- load on the drminfo app, scroll down to "Widevine CDM" section for version
Hi @rrfrias, thanks for your answer
In our tests the rental duration of the license is 30 days and the playback duration is 48 hours. I don't know the license duration.
Before the first playback the 'license duration' returned by getLicenseDurationRemainingSec() method is set to rental duration for all devices (the value count down and change each second). For All devices the playback duration returned is 172800 (48 hours) and stay the same. So it is okay at this point.
After the first playback 'license duration' returned by getLicenseDurationRemainingSec() method is set to Long.MAX_VALUE but only on our Pixel and OnePlus and not on our Huawei and Samsung.
It's convenient to know the value to use to display remaining time to the user but I'm not sure if this this the expected comportement on all devices or if this is a constructor implementation choice.
If this is constructor implementation choice how to know if there has already been a playback on the media ?
Device informations :
Samsung Galaxy S10 SM-G973F Android 11 (up-to-date) Widevine version 16.0.0
Huawei P30 lite MAR-LX1A Android 10 (up-to-date) Widevine version 15.0.0
OnePlus Nord AC2003 Android 11 (up-to-date) Widevine version 16.0.0
Pixel 3a Android 11 (up-to-date) Widevine version 15.0.0
Hi @rrfrias @icbaker, any news on this question ?
On some devices like Pixel or OnePlus the 'license duration' is set to Long.MAX_VALUE after the first playback so this is possible to get the right value using the following code
This behavior depends on the license policy. Can you save a license response (base64 encoded or hex) received at the client and email it to [email protected] with subject "Issue #9493". One for the working devices and another for the devices experiencing failure. If the device is running android 12.0, a bugreport will capture the license so no need to send it separately. A bugreport for the Samsung Galaxy S 10 might be helpful as well.
One possibility is that the license policy specifies soft enforce rental duration. This only works for devices that are Widevine 16.0.0 and above. This might explain the Huawei P30 license duration keeps counting down after playback begins.
A crude alternative to detect playback, by checking the playback duration remaining twice after a short delay and verifying that the value was counting down.
Hey @laruedavid. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
@rrfrias we sent more details about our licenses using the process described above
Sorry, about not getting back. We changed the way our policies work in android 11 (technically an internal implementation v16) that new android 16 devices will support and that devices upgrading toe android 16 may support. Bcakwards compatibility of policies for older devices is supported.
If you are a Widevine Integration Partner, you can contact Widevine support to receive documentation on the license policies. If you are not, you can sign an agreement to become one at no cost.
If you still face problems, do let us know.
Hey @laruedavid. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@laruedavid if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.