Tips for using Widevine iOS SDK

Get license for a local file:

  • If the file has not been registered before, call WV_Register() to register the file to WV local DB.
  • Re-register a pre-registered file returns 4100 from WV_Register().
  • After register success, call WV_NowOnline() to get license from lic server.
  • You need to make sure WV_Register() returns success before call WV_NowOnline. With 4100 returned from WV_Register(), WV_NowOnline() does nothing for you (it won’t go online and acquire the license). If 4100 returned but you don’t have valid license now, UnRegister this file and ReRegister it again followed a WV_NowOnline call.
  • If WV_NowOnline is called without network connection, it doesn’t return anything. So make sure you check the network connection before call this API.
  • If license acquisition fails, WViOsApiEvent_EMMFailed will be dispatched. Check “WVStatusKey” in its attribute and the value should be 6 which means “No license”.
  • If license acquisition success, you might receive WViOsApiEvent_EMMFailed first with WVStatusKey set to 6, and you will receive WViOsApiEvent_QueryStatus some time after that with WVStatusKey set to 0 which means OK (license is ready).

So this is what you need to do for acquiring the license:

  1. Get the local file ready.
  2. Call WV_Register() to register the file.
  3. Check the return value:
    1. If its OK (0), call WV_QueryAssetStatus and check the WVStatusKey.
      1. 0: License is ready. You can go and play the title.
      2. 6 (and other): No license, pls go and do next steps.
    2. If it fails with 4100, call WV_UnregisterAsset first and WV_RegisterAsset again.
  4. Check if it’s online now, only call WV_NowOnline when the network connection is live.
  5. Call WV_NowOnline()
    1. Wait for status callback event
      1. If WViOsApiEvent_EMMReceived, we are done.
      2. If WViOsApiEvent_EMMFailed, wait a second (maybe two) to see if you can receive the WViOsApiEvent_QueryStatus event. If you cannot, keep calling WV_QueryAssetStatus() after that for about 10 times (1 per second)
    2. Check the WVStatusKey in WViOsApiEvent_QueryStatus
      1. 0: License is ready. You can go and play the title.
      2. 6 (and other): No license.
  6. Done.

Now you can call WV_Play() to play the video.

How to check if you have a license for a video:

  • Call WV_QueryAssetStatus(filePath)
  • In the WViOsApiEvent_QueryStatus event, check WVStatusKey
    • 0: License is ready. You can go and play the title.
    • 6 (and other): No license.


Fill in your details below or click an icon to log in: 徽标

You are commenting using your account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s