1

アプリケーションに DRM を実装しようとしています。
しかし、私は問題に直面しています。canHandle()常に false を返します。
そしてDrmManagerClient.getOriginalMimeType(Uri); http リンクの場合は常に null を返します。
しかし、ストレージ内のファイルについては、すべて正常に機能しています。

DrmManagerClient mDrmManager;
mDrmManager = new DrmManagerClient(this);
String testUri = myUrl;
String mimeType = getOriginalMimeType( testUri );

以下は mimetype を取得する方法ですが、残念ながら canHandle() は常に false を返します。

    // get MimeType
public String getOriginalMimeType(String uri){
    String mime = null;

    try {
        if( mDrmManager.canHandle(Uri.parse(uri), null) ){
            mime = mDrmManager.getOriginalMimeType(Uri.parse(uri));
        }
    } catch (Exception e) {
        Log.w(TAG, e.toString());
    }

    return mime;
}

何か不足していますか?
明らかに、私が使用している URL はおそらく適切ではありませんが、別のアプリケーションで動作する別の URL を試してみましたが、結果は同じです。
マニフェスト ファイルにも INTERNET 権限を設定しました。何が問題なのか、アイデアが不足しています。
DrmManagerClient のソース コードを調べたところ、canHandle() が次のように定義されていることに気付きました。

/**
 * Checks whether the given MIME type or URI can be handled.
 *
 * @param uri URI for the content to be handled.
 * @param mimeType MIME type of the object to be handled
 *
 * @return True if the given MIME type or URI can be handled; false if they cannot be handled.
 */
public boolean canHandle(Uri uri, String mimeType) {
    if ((null == uri || Uri.EMPTY == uri) && (null == mimeType || mimeType.equals(""))) {
        throw new IllegalArgumentException("Uri or the mimetype should be non null");
    }
    return canHandle(convertUriToPath(uri), mimeType);
}

Uri を Path に変換しているため、canHandle(Uri uri , String mimeType)基本的には同じです。 これは、Http URL が機能しないということですか?canHandle( String path, mimeType )

4

1 に答える 1

0

問題は URL にあることがわかりました。
これら 2 つのリンクでテストしたところ、すべて問題ありません。

ストリーム 1: http://commondatastorage.googleapis.com/wvmedia/sintel_main_720p_4br_tp.wvm

ストリーム 2: http://commondatastorage.googleapis.com/wvmedia/starz_main_720p_6br_tp.wvm

将来誰かに役立つことを願っています。

于 2014-06-23T06:12:11.063 に答える