1

我正在 Exoplayer Android 上实现一个 OTT 应用程序。我们正在使用 Widewine DRM 保护我们的内容。但我们得到了如下所示的错误。

 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err: com.google.android.exoplayer2.drm.UnsupportedDrmException: android.media.UnsupportedSchemeException: Failed to instantiate drm object.
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.google.android.exoplayer2.drm.FrameworkMediaDrm.newInstance(FrameworkMediaDrm.java:50)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.cinesoft.cinehome.player.PlayerActivity.buildDrmSessionManager(PlayerActivity.java:483)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.cinesoft.cinehome.player.PlayerActivity.initPlayer(PlayerActivity.java:398)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.cinesoft.cinehome.player.PlayerActivity.onPlayRequestResult(PlayerActivity.java:1308)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.cinesoft.cinehome.api.services.ConnectToServer$3.onResponse(ConnectToServer.java:503)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.cinesoft.cinehome.api.services.ConnectToServer$3.onResponse(ConnectToServer.java:483)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:65)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at android.os.Handler.handleCallback(Handler.java:739)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at android.os.Looper.loop(Looper.java:148)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7325)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err: Caused by: android.media.UnsupportedSchemeException: Failed to instantiate drm object.
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at android.media.MediaDrm.native_setup(Native Method)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at android.media.MediaDrm.<init>(MediaDrm.java:215)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.google.android.exoplayer2.drm.FrameworkMediaDrm.<init>(FrameworkMediaDrm.java:57)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     at com.google.android.exoplayer2.drm.FrameworkMediaDrm.newInstance(FrameworkMediaDrm.java:48)
 06-13 17:31:53.641 18652-18652/com.cinesoft.cinehome.android W/System.err:     ... 14 more

代码如下所示

mediaDataSourceFactory = buildDataSourceFactory(true);
        mainHandler = new Handler();
        bandwidthMeter = new DefaultBandwidthMeter();

        videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);

        trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
        eventLogger = new EventLogger(trackSelector);
        if (JsonParser.sStr_drmStatus.equalsIgnoreCase("1")) {
            AndroidDeviceIdentifier androidDeviceIdentifier = new AndroidDeviceIdentifier();
            UUID drmSchemeUuid = null;
            drmSchemeUuid = UUID.fromString(androidDeviceIdentifier.getUniqueDeviceIdentifier(PlayerActivity.this));
            drmSessionManager = null;
            if (drmSchemeUuid != null) {
                String drmLicenseUrl = ConnectPortalSettings.WIDEVINE_LICENSE_SERVER_URL;
                String[] keyRequestPropertiesArray = new String[]{};
                //                drmLicenseUrl = intent.getStringExtra(DRM_LICENSE_URL);
                //                keyRequestPropertiesArray = intent.getStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES);
                try {
                    drmSessionManager = buildDrmSessionManager(drmSchemeUuid, drmLicenseUrl,
                            keyRequestPropertiesArray);
                } catch (UnsupportedDrmException e) {
                    int errorStringId = Util.SDK_INT < 18 ? R.string.error_drm_not_supported
                            : (e.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
                            ? R.string.error_drm_unsupported_scheme : R.string.error_drm_unknown);
                    e.printStackTrace();
                    Log.e("Drm Error Code", String.valueOf(errorStringId));
                    return;
                }
            }
            @SimpleExoPlayer.ExtensionRendererMode int extensionRendererMode =
                    ((BaseApplication) getApplication()).useExtensionRenderers()
                            ? (false ? SimpleExoPlayer.EXTENSION_RENDERER_MODE_PREFER
                            : SimpleExoPlayer.EXTENSION_RENDERER_MODE_ON)
                            : SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF;
            LoadControl loadControl = new DefaultLoadControl();
 // 3. Create the player

                 player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl,
                    drmSessionManager, extensionRendererMode);
        } else {
            LoadControl loadControl = new DefaultLoadControl();
            player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
        }

请帮我解决这个问题。提前致谢。

4

2 回答 2

2

转储中有很多数据可能会令人困惑和分散注意力,但您需要关注的错误是:

android.media.UnsupportedSchemeException:无法实例化drm对象

你是在模拟器上运行的吗?您可能需要在真实设备上运行它才能进行测试。在以下位置查看更多信息: https ://github.com/google/ExoPlayer/issues/1616

如果您没有在模拟器上运行并且您在设备上运行,那么您运行它的设备可能会出现问题,如下所示: https ://github.com/google/ExoPlayer/issues/2260

另外,请注意,当我们关注该错误时,我们也认识到它是: UnsupportedSchemeException

尝试使用设备不支持的加密方案 UUID 构造 MediaDrm 对象时引发异常

来自: https ://developer.android.com/reference/android/media/UnsupportedSchemeException.html

于 2017-06-13T12:38:16.003 回答
1

正如 raddevus 所说,该错误表示播放器无法识别 DRM 方案标识符。

不同的 DRM 具有不同的方案 ID -widevines 是“urn:uuid:EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED”。

可能包含了错误的方案 id,或者没有正确读取编码。

还值得检查 MPD 是否包含保护信息 - 规范说它应该在 MPD 和 MP4 PSSH 标头中,但一些打包程序仅将它包含在 MP4 PSSH 标头中,在这种情况下,Exoplayer 不会在其中找到它MPD。

于 2017-06-15T08:05:08.247 回答