[Android] src: Show embedded art from media as well

XilasZ xilasz at gmail.com
Thu Jun 28 22:54:00 CEST 2012


What's the purpose of this ? Embedded arts were already working
Le 28 juin 2012 20:50, "Edward Wang" <git at videolan.org> a écrit :

> android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> |
> Thu Jun 28 14:45:46 2012 -0400| [c00e6f2a8cad31763af8639b03c7e2686972bdf9]
> | committer: Edward Wang
>
> src: Show embedded art from media as well
>
> >
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=c00e6f2a8cad31763af8639b03c7e2686972bdf9
> ---
>
>  vlc-android/src/org/videolan/vlc/AudioService.java |   34
> +++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java
> b/vlc-android/src/org/videolan/vlc/AudioService.java
> index e057500..73aed95 100644
> --- a/vlc-android/src/org/videolan/vlc/AudioService.java
> +++ b/vlc-android/src/org/videolan/vlc/AudioService.java
> @@ -21,6 +21,8 @@
>  package org.videolan.vlc;
>
>  import java.io.File;
> +import java.math.BigInteger;
> +import java.security.MessageDigest;
>  import java.util.ArrayList;
>  import java.util.HashMap;
>  import java.util.List;
> @@ -433,8 +435,38 @@ public class AudioService extends Service {
>
>             //cover not in MediaStore, trying vlc
>             String artworkURL = mCurrentMedia.getArtworkURL();
> -            if (artworkURL != null && artworkURL.startsWith("file://"))
> +            final String cacheDir =
> "/sdcard/Android/data/org.videolan.vlc/cache";
> +            if (artworkURL != null && artworkURL.startsWith("file://")) {
>                 return
> BitmapFactory.decodeFile(Uri.decode(artworkURL).replace("file://", ""));
> +            } else if(artworkURL != null &&
> artworkURL.startsWith("attachment://")) {
> +                // Decode if the album art is embedded in the file
> +                String mArtist = mCurrentMedia.getArtist();
> +                String mAlbum = mCurrentMedia.getAlbum();
> +
> +                /* 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 +
> mCurrentMedia.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 = cacheDir + "/art/arturl/" + titleHash +
> "/art.png";
> +                } else {
> +                    /* Otherwise, it was cached by artist and album */
> +                    artworkURL = cacheDir + "/art/artistalbum/" + mArtist
> + "/" + mAlbum + "/art.png";
> +                }
> +
> +                Log.v(TAG, "artworkURL (calculated) = " + artworkURL);
> +                return BitmapFactory.decodeFile(artworkURL);
> +            }
>
>             //still no cover found, looking in folder ...
>             File f = Util.URItoFile(mCurrentMedia.getLocation());
>
> _______________________________________________
> Android mailing list
> Android at videolan.org
> http://mailman.videolan.org/listinfo/android
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20120628/b11d0a12/attachment.html>


More information about the Android mailing list