问题
I am developing an application that is meant to playback Widevine protected contents. I am trying to run application on Genymotion virtual Android device. But when I do so application fails to acquire DRM info. Thus following code returns null and application won't proceed further.
DrmInfoRequest request = new DrmInfoRequest(DrmInfoRequest.TYPE_REGISTRATION_INFO,
Settings.WIDEVINE_MIME_TYPE);
request.put("WVPortalKey", portal);
DrmInfo response = mDrmManager.acquireDrmInfo(request);
I am wondering if genymotion virtual device is cause of the problem. If so, is it possible to configure genymotion such that it works with DRM? Any help would be highly appreciated.
回答1:
private final static long DEVICE_IS_PROVISIONED = 0;
private final static long DEVICE_IS_NOT_PROVISIONED = 1;
private final static long DEVICE_IS_PROVISIONED_SD_ONLY = 2;
private final static String WIDEVINE_MIME_TYPE = "video/wvm";
public static boolean isDeviceWidevineDRMProvisioned(Context context)
{
boolean isDrmAvailable = true;
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion < android.os.Build.VERSION_CODES.KITKAT)
{
//As Media DRM Package is available only after KITKAT(API Level 19)
isDrmAvailable = false;
} else
{
DrmManagerClient drmManagerClient = new DrmManagerClient(context);
DrmInfoRequest drmInfoRequest = new DrmInfoRequest(DrmInfoRequest.TYPE_REGISTRATION_INFO, WIDEVINE_MIME_TYPE);
drmInfoRequest.put("WVPortalKey", "key provided for drm in widevine portal");
DrmInfo drmInfo = drmManagerClient.acquireDrmInfo(drmInfoRequest);
if (drmInfo != null)
{
String kWVDrmInfoRequestStatusKey = (String) drmInfo.get("WVDrmInfoRequestStatusKey");
String drmPath = (String) drmInfo.get("drm_path");
if ((kWVDrmInfoRequestStatusKey != null && Integer.parseInt(kWVDrmInfoRequestStatusKey) == DEVICE_IS_NOT_PROVISIONED) || (drmPath != null && drmPath.length() == 0))
{
//not supported
isDrmAvailable = false;
}
}
}
return isDrmAvailable;
}
回答2:
The above method doesn't work for me, acquireDrmInfo(request) always return null. After study Exo-player DashTestRunner. I use following method to get the Widevine DRM information.
private static final UUID WIDEVINE_UUID = new UUID(0xEDEF8BA979D64ACEL, 0xA3C827DCD51D21EDL);
@TargetApi (Build.VERSION_CODES.JELLY_BEAN_MR2)
@SuppressWarnings("ResourceType")
private void getWVDrmInfo() {
MediaDrm mediaDrm = null;
try {
mediaDrm = new MediaDrm(WIDEVINE_UUID);
String vendor = mediaDrm.getPropertyString(MediaDrm.PROPERTY_VENDOR);
String version = mediaDrm.getPropertyString(MediaDrm.PROPERTY_VERSION);
String description = mediaDrm.getPropertyString(MediaDrm.PROPERTY_DESCRIPTION);
String algorithms = mediaDrm.getPropertyString(MediaDrm.PROPERTY_ALGORITHMS);
String securityLevel = mediaDrm.getPropertyString("securityLevel");
String systemId = mediaDrm.getPropertyString("systemId");
String hdcpLevel = mediaDrm.getPropertyString("hdcpLevel");
String maxHdcpLevel = mediaDrm.getPropertyString("maxHdcpLevel");
String usageReportingSupport = mediaDrm.getPropertyString("usageReportingSupport");
String maxNumberOfSessions = mediaDrm.getPropertyString("maxNumberOfSessions");
String numberOfOpenSessions = mediaDrm.getPropertyString("numberOfOpenSessions");
mediaDrm.release();
} catch (UnsupportedSchemeException e) {
e.printStackTrace();
}
}
回答3:
DRM is a hardware feature. It can't be obtained in emulators.
回答4:
You can registrer error listeners on the manager to get a clue of what is happening:
manager.setOnErrorListener(new DrmManagerClient.OnErrorListener() {
public void onError(DrmManagerClient drmManagerClient, DrmErrorEvent event) {
Log.i(TAG, "Error Type : " + event.getType());
}
});
来源:https://stackoverflow.com/questions/24892532/drmmanagerclient-acquiredrminfo-is-failing