0
我需要離線播放受DRM保護的內容。我將兩個文件存儲在本地存儲中;一個指向相同目錄中的mp4文件的破折號文件。離線播放受DRM保護的內容
該文件的密鑰也存儲在數據庫中,並在播放啓動時被檢索。
然而,建立DRM會議結束後,下面的錯誤被拋出:
playerFailed [1.04]
com.google.android.exoplayer2.ExoPlaybackException
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:691)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:507)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:466)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:300)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.google.android.exoplayer2.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
Caused by: android.media.MediaCodec$CryptoException: Error decrypting data: requested key has not been loaded
at android.media.MediaCodec.native_queueSecureInputBuffer(Native Method)
at android.media.MediaCodec.queueSecureInputBuffer(MediaCodec.java:2292)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:682)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:507)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:466)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:300)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.google.android.exoplayer2.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
我用這個塊檢查一個給定的軌道是否有一個鍵或不要求換一個新的了。
private DrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(UUID uuid, String licenseURL,
Map<String, String> keyRequestProperties) throws UnsupportedDrmException {
HttpMediaDrmCallback drmCallback = new HttpMediaDrmCallback(licenseURL, buildHttpDataSourceFactory(false), keyRequestProperties);
defaultDrmSessionManager = new DefaultDrmSessionManager<>(uuid, FrameworkMediaDrm.newInstance(uuid), drmCallback, null, mainHandler, eventLogger);
if (track != null) {
DrmKey key = realm.where(DrmKey.class).equalTo("trackId", track.getId()).findFirst();
Log.e("TrackId", track.getId());
if (key != null) {
byte[] offlineKeySetId = Base64.decode(key.getRequestKey(), Base64.DEFAULT);
defaultDrmSessionManager.setMode(DefaultDrmSessionManager.MODE_QUERY, offlineKeySetId);
Log.e("Key", key.getRequestKey());
Log.e(MusicService.class.getSimpleName(), "OfflineKeySet already defined, using the existing one : " + key.getRequestKey());
} else {
defaultDrmSessionManager.setMode(DefaultDrmSessionManager.MODE_DOWNLOAD, null);
Log.e(MusicService.class.getSimpleName(), "Offline key not defined, retrieving a new licence");
}
}
return defaultDrmSessionManager;
}
對於所有的脫機文件我嘗試玩,關鍵是始終可用。那麼爲什麼外行人不能播放任何文件呢?