[Android] [PATCH 4/4] Audio Streams : Display NowPlaying metadata

Jean-Baptiste Kempf jb at videolan.org
Tue Nov 25 11:39:25 CET 2014


This needs a bit more work.

On 24 Nov, Alexandre Perraud wrote :
>     fix #12815
> ---
>  libvlc/src/org/videolan/libvlc/Media.java          | 42 ++++++++++++++++++++--
>  .../src/org/videolan/vlc/audio/AudioService.java   |  7 ++++
>  2 files changed, 46 insertions(+), 3 deletions(-)
> 
> diff --git a/libvlc/src/org/videolan/libvlc/Media.java b/libvlc/src/org/videolan/libvlc/Media.java
> index 5f10054..6ad91c2 100644
> --- a/libvlc/src/org/videolan/libvlc/Media.java
> +++ b/libvlc/src/org/videolan/libvlc/Media.java
> @@ -111,6 +111,30 @@ public class Media implements Comparable<Media> {
>      private String mTrackID;
>      private String mArtworkURL;
>  
> +    public final static int libvlc_meta_Title       = 0;
> +    public final static int libvlc_meta_Artist      = 1;
> +    public final static int libvlc_meta_Genre       = 2;
> +//    public final static int libvlc_meta_Copyright   = 3;
> +    public final static int libvlc_meta_Album       = 4;
> +//    public final static int libvlc_meta_TrackNumber = 5;
> +//    public final static int libvlc_meta_Description = 6;
> +//    public final static int libvlc_meta_Rating      = 7;
> +//    public final static int libvlc_meta_Date        = 8;
> +//    public final static int libvlc_meta_Setting     = 9;
> +//    public final static int libvlc_meta_URL         = 10;
> +//    public final static int libvlc_meta_Language    = 11;
> +    public final static int libvlc_meta_NowPlaying  = 12;
> +//    public final static int libvlc_meta_Publisher   = 13;
> +//    public final static int libvlc_meta_EncodedBy   = 14;
> +    public final static int libvlc_meta_ArtworkURL  = 15;
> +//    public final static int libvlc_meta_TrackID     = 16;
> +//    public final static int libvlc_meta_TrackTotal  = 17;
> +//    public final static int libvlc_meta_Director    = 18;
> +//    public final static int libvlc_meta_Season      = 19;
> +//    public final static int libvlc_meta_Episode     = 20;
> +//    public final static int libvlc_meta_ShowName    = 21;
> +//    public final static int libvlc_meta_Actors      = 22;
> +
>      private final String mLocation;
>      private String mFilename;
>      private long mTime = 0;
> @@ -271,8 +295,17 @@ public class Media implements Comparable<Media> {
>          return mLocation;
>      }
>  
> -    public void updateMeta() {
> -
> +    public void updateMeta(LibVLC libVLC) {
> +        mTitle = libVLC.getMeta(libvlc_meta_Title);
> +        mArtist = getValueWrapper(libVLC.getMeta(libvlc_meta_Artist), UnknownStringType.Artist);
> +        mGenre = getValueWrapper(libVLC.getMeta(libvlc_meta_Genre), UnknownStringType.Genre);
> +        mAlbum = getValueWrapper(libVLC.getMeta(libvlc_meta_Album), UnknownStringType.Album);
> +        mNowPlaying = libVLC.getMeta(libvlc_meta_NowPlaying);
> +        mArtworkURL = libVLC.getMeta(libvlc_meta_ArtworkURL);
> +        if (mNowPlaying != null) {
> +            mArtist = mNowPlaying;
> +            mAlbum = "";
> +        }
>      }
>  
>      public String getFileName() {
> @@ -368,7 +401,10 @@ public class Media implements Comparable<Media> {
>      }
>  
>      public String getSubtitle() {
> -        return mType != TYPE_VIDEO ? mArtist + " - " + mAlbum : "";
> +        return mType != TYPE_VIDEO ?
> +                mNowPlaying != null ?
> +                        mNowPlaying
> +                        : mArtist + " - " + mAlbum : "";
>      }
>  
>      public String getArtist() {
> diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
> index bf4e85f..654e8aa 100644
> --- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
> +++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
> @@ -524,6 +524,13 @@ public class AudioService extends Service {
>                  case EventHandler.MediaPlayerTimeChanged:
>                      // avoid useless error logs
>                      break;
> +                case EventHandler.MediaMetaChanged:
> +                    service.getCurrentMedia().updateMeta(service.mLibVLC);
> +                    service.setUpRemoteControlClient();
> +                    service.executeUpdate();
> +                    service.showNotification();
> +                    service.updateRemoteControlClientMetadata();
> +                    break;
>                  default:
>                      Log.e(TAG, String.format("Event not handled (0x%x)", msg.getData().getInt("event")));
>                      break;
> -- 
> 2.1.0
> 
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android

-- 
With my kindest regards,

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device


More information about the Android mailing list