Android DrmManagerClient适用于本地文件,但不适用于服务器中的文件
我正在尝试在我的应用程序中实现DRM。 但我面临一个问题。canHandle总是返回false。 和DrmManagerClient.getoriginalmmetypeuri;http链接始终返回null。 但是对于存储中的文件,一切都正常 下面是获取mimetype的方法,但不幸的是canHandle总是返回falseAndroid DrmManagerClient适用于本地文件,但不适用于服务器中的文件,android,drm,android-drm,Android,Drm,Android Drm,我正在尝试在我的应用程序中实现DRM。 但我面临一个问题。canHandle总是返回false。 和DrmManagerClient.getoriginalmmetypeuri;http链接始终返回null。 但是对于存储中的文件,一切都正常 下面是获取mimetype的方法,但不幸的是canHandle总是返回false // get MimeType public String getOriginalMimeType(String uri){ String mime = nu
// 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);
}
canHandleUri uri,String mimeType与canHandle String path,mimeType基本相同,因为它将uri转换为path。
这是否意味着Http URL无法工作?我发现问题在于URL。 我测试了这两个链接,现在一切都很好 流1: 流2:
希望这对将来的人有所帮助。你好,忍者,我正在尝试在我的应用程序中实现DRM,遇到了很多问题,你能提供一些关于这方面的示例吗。这将非常有帮助,谢谢advance@KomalG当时我在三星网站上找到的最容易理解的样本。我现在找不到。看看这个。您好,懒惰的忍者,非常感谢您的回复,我看到了我在DroidTest项目中找到的niceplugin链接==>WidevineDrm.java和VideoViewWidevineActivity.java我正在播放来自内部存储/存储/模拟/0/Android/的视频,使用上述两个文件将视频取出并推入另一个设备,该视频播放良好,没有任何问题视频未受到保护我的目标是在使用DRM播放时保护视频不受其他设备的影响DrmManagerClient无法处理媒体文件请解释请解释忍者谢谢Shello忍者plz提供任何关于此的示例。这将非常有帮助提前表示完全感谢
/**
* 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);
}