本文整理汇总了Java中org.videolan.vlc.MediaWrapper.getArtworkURL方法的典型用法代码示例。如果您正苦于以下问题:Java MediaWrapper.getArtworkURL方法的具体用法?Java MediaWrapper.getArtworkURL怎么用?Java MediaWrapper.getArtworkURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.videolan.vlc.MediaWrapper
的用法示例。
在下文中一共展示了MediaWrapper.getArtworkURL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCoverFromVlc
import org.videolan.vlc.MediaWrapper; //导入方法依赖的package包/类
private static String getCoverFromVlc(Context context, MediaWrapper media) throws NoSuchAlgorithmException, UnsupportedEncodingException {
String artworkURL = media.getArtworkURL();
if (artworkURL != null && artworkURL.startsWith("file://")) {
return Uri.decode(artworkURL).replace("file://", "");
} else if(artworkURL != null && artworkURL.startsWith("attachment://")) {
// Decode if the album art is embedded in the file
String mArtist = Util.getMediaArtist(context, media);
String mAlbum = Util.getMediaAlbum(context, media);
/* Parse decoded attachment */
if( mArtist.length() == 0 || mAlbum.length() == 0 ||
mArtist.equals(VLCApplication.getAppContext().getString(R.string.unknown_artist)) ||
mAlbum.equals(VLCApplication.getAppContext().getString(R.string.unknown_album)) )
{
/* If artist or album are missing, it was cached by title MD5 hash */
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] binHash = md.digest((artworkURL + media.getTitle()).getBytes("UTF-8"));
/* Convert binary hash to normal hash */
BigInteger hash = new BigInteger(1, binHash);
String titleHash = hash.toString(16);
while(titleHash.length() < 32) {
titleHash = "0" + titleHash;
}
/* Use generated hash to find art */
artworkURL = ART_DIR + "/arturl/" + titleHash + "/art.png";
} else {
/* Otherwise, it was cached by artist and album */
artworkURL = ART_DIR + "/artistalbum/" + mArtist + "/" + mAlbum + "/art.png";
}
return artworkURL;
}
return null;
}
示例2: getCoverFromVlc
import org.videolan.vlc.MediaWrapper; //导入方法依赖的package包/类
private static String getCoverFromVlc(Context context, MediaWrapper media) throws NoSuchAlgorithmException, UnsupportedEncodingException {
String artworkURL = media.getArtworkURL();
if (artworkURL != null && artworkURL.startsWith("file://")) {
return Uri.decode(artworkURL).replace("file://", "");
} else if(artworkURL != null && artworkURL.startsWith("attachment://")) {
// Decode if the album art is embedded in the file
String mArtist = Util.getMediaArtist(context, media);
String mAlbum = Util.getMediaAlbum(context, media);
/* Parse decoded attachment */
if( mArtist.length() == 0 || mAlbum.length() == 0 ||
mArtist.equals(VLCApplication.getAppContext().getString(R.string.unknown_artist)) ||
mAlbum.equals(VLCApplication.getAppContext().getString(R.string.unknown_album)) )
{
/* If artist or album are missing, it was cached by title MD5 hash */
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] binHash = md.digest((artworkURL + media.getTitle()).getBytes("UTF-8"));
/* Convert binary hash to normal hash */
BigInteger hash = new BigInteger(1, binHash);
String titleHash = hash.toString(16);
while(titleHash.length() < 32) {
titleHash = "0" + titleHash;
}
/* Use generated hash to find art */
artworkURL = ART_DIR + "/arturl/" + titleHash + "/art.png";
} else {
/* Otherwise, it was cached by artist and album */
artworkURL = ART_DIR + "/artistalbum/" + mArtist + "/" + mAlbum + "/art.png";
}
return artworkURL;
}
return null;
}