<p>What's the purpose of this ? Embedded arts were already working</p>
<div class="gmail_quote">Le 28 juin 2012 20:50, "Edward Wang" <<a href="mailto:git@videolan.org">git@videolan.org</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
android | branch: master | Edward Wang <<a href="mailto:edward.c.wang@compdigitec.com">edward.c.wang@compdigitec.com</a>> | Thu Jun 28 14:45:46 2012 -0400| [c00e6f2a8cad31763af8639b03c7e2686972bdf9] | committer: Edward Wang<br>
<br>
src: Show embedded art from media as well<br>
<br>
> <a href="http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=c00e6f2a8cad31763af8639b03c7e2686972bdf9" target="_blank">http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=c00e6f2a8cad31763af8639b03c7e2686972bdf9</a><br>
---<br>
<br>
vlc-android/src/org/videolan/vlc/AudioService.java | 34 +++++++++++++++++++-<br>
1 file changed, 33 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java<br>
index e057500..73aed95 100644<br>
--- a/vlc-android/src/org/videolan/vlc/AudioService.java<br>
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java<br>
@@ -21,6 +21,8 @@<br>
package org.videolan.vlc;<br>
<br>
import java.io.File;<br>
+import java.math.BigInteger;<br>
+import java.security.MessageDigest;<br>
import java.util.ArrayList;<br>
import java.util.HashMap;<br>
import java.util.List;<br>
@@ -433,8 +435,38 @@ public class AudioService extends Service {<br>
<br>
//cover not in MediaStore, trying vlc<br>
String artworkURL = mCurrentMedia.getArtworkURL();<br>
- if (artworkURL != null && artworkURL.startsWith("file://"))<br>
+ final String cacheDir = "/sdcard/Android/data/org.videolan.vlc/cache";<br>
+ if (artworkURL != null && artworkURL.startsWith("file://")) {<br>
return BitmapFactory.decodeFile(Uri.decode(artworkURL).replace("file://", ""));<br>
+ } else if(artworkURL != null && artworkURL.startsWith("attachment://")) {<br>
+ // Decode if the album art is embedded in the file<br>
+ String mArtist = mCurrentMedia.getArtist();<br>
+ String mAlbum = mCurrentMedia.getAlbum();<br>
+<br>
+ /* Parse decoded attachment */<br>
+ if( mArtist.length() == 0 || mAlbum.length() == 0 ||<br>
+ mArtist.equals(VLCApplication.getAppContext().getString(R.string.unknown_artist)) ||<br>
+ mAlbum.equals(VLCApplication.getAppContext().getString(R.string.unknown_album)) )<br>
+ {<br>
+ /* If artist or album are missing, it was cached by title MD5 hash */<br>
+ MessageDigest md = MessageDigest.getInstance("MD5");<br>
+ byte[] binHash = md.digest((artworkURL + mCurrentMedia.getTitle()).getBytes("UTF-8"));<br>
+ /* Convert binary hash to normal hash */<br>
+ BigInteger hash = new BigInteger(1, binHash);<br>
+ String titleHash = hash.toString(16);<br>
+ while(titleHash.length() < 32) {<br>
+ titleHash = "0" + titleHash;<br>
+ }<br>
+ /* Use generated hash to find art */<br>
+ artworkURL = cacheDir + "/art/arturl/" + titleHash + "/art.png";<br>
+ } else {<br>
+ /* Otherwise, it was cached by artist and album */<br>
+ artworkURL = cacheDir + "/art/artistalbum/" + mArtist + "/" + mAlbum + "/art.png";<br>
+ }<br>
+<br>
+ Log.v(TAG, "artworkURL (calculated) = " + artworkURL);<br>
+ return BitmapFactory.decodeFile(artworkURL);<br>
+ }<br>
<br>
//still no cover found, looking in folder ...<br>
File f = Util.URItoFile(mCurrentMedia.getLocation());<br>
<br>
_______________________________________________<br>
Android mailing list<br>
<a href="mailto:Android@videolan.org">Android@videolan.org</a><br>
<a href="http://mailman.videolan.org/listinfo/android" target="_blank">http://mailman.videolan.org/listinfo/android</a><br>
</blockquote></div>