Metadata script for any player. Requires android.permission.MEDIA_CONTENT_CONTROL !

Metadata script for any player. Requires android.permission.MEDIA_CONTENT_CONTROL !

Albumart works too, but is currently saved as an Image object in the global variable globalAA, because bindings can’t hold images.

This should work with any player on any device with Lollipop or higher.

]]>

19 Commentsto Metadata script for any player. Requires android.permission.MEDIA_CONTENT_CONTROL !

  1. Anonymous says:

    < ![CDATA[

    LL.bindClass(“android.media.session.MediaSessionManager”);


    LL.bindClass(“android.media.session.MediaController”);


    LL.bindClass(“android.media.MediaMetadata”);


    LL.bindClass(“java.util.ArrayList”);



    var c=LL.getContext();


    var m=c.getSystemService(Context.MEDIA_SESSION_SERVICE);


    var callback=new JavaAdapter(MediaController.Callback,{onMetadataChanged:function(md){


    if(md==null)return;


    var v=LL.getVariables();


    var e=v.edit();


    var title=md.getString(MediaMetadata.METADATA_KEY_TITLE);


    if(title==null)title=””;


    e.setString(“track”,title);


    var album=md.getString(MediaMetadata.METADATA_KEY_ALBUM);


    if(album==null)album=””;


    e.setString(“album”,album);


    var artist=md.getString(MediaMetadata.METADATA_KEY_ARTIST);


    if(artist==null)artist=””;


    e.setString(“artist”,artist);


    setTimeout(function(){


    var aa=md.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART);


    if(aa!=null){


    globalAA=LL.createImage(aa.getWidth(),aa.getHeight());


    globalAA.draw().drawBitmap(aa,0,0,null);


    globalAA.update();


    aa.recycle();


    e.setFloat(“aachange”,Math.random());


    }


    e.commit();


    },0);


    e.commit();


    }});


    var sessions=new ArrayList();


    var listener=new MediaSessionManager.OnActiveSessionsChangedListener(){


    onActiveSessionsChanged:function(se){


    var n=new ArrayList(se);


    n.removeAll(sessions);


    for(var i=0;i


    var s=n.get(i);


    s.registerCallback(callback);


    callback.onMetadataChanged(s.getMetadata());


    sessions.removeAll(se);


    for(var i=0;i


    var s=sessions.get(i);


    s.unregisterCallback(callback);


    }


    sessions=se;


    }


    }


    };


    var a=m.getActiveSessions(null);


    listener.onActiveSessionsChanged(a);


    m.addOnActiveSessionsChangedListener(listener,null);

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Woo hoo!

    ]]>

  3. Anonymous says:

    < ![CDATA[

    You might notice I’m going crazy on metadata right now. I think I should say: this version is experimental and can crash the launcher. I would advise to not set it in the load event but instead starting it manually after every restart.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    We appreciate your craziness 🙂

    ]]>

  5. Anonymous says:

    < ![CDATA[

    fantastic! does this work with youtube (since it doesn’t play media files but rather video streams)?

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Wern-Yuen Tan yes! (thumbnail and title)

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Wow, is it making LLx Music widget ?

    ]]>

  8. Anonymous says:

    < ![CDATA[

    This version definetly has a memory leak. → *Not for everyday usage!* Memory leak fixed

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Pierre Hébert could you create a package for this permission, so non-root users can use this script too?

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Lukas Morawietz please explain how to use. I’m running from the desktop : nothing.


    From a music widget : nothing

    ]]>

  11. Anonymous says:

    < ![CDATA[

    Bruno-Isa LAMOUR-ARNOULD


    This is used like the old metadata script: You set it in load and it just sets variables (for bindings). The albumcover is a bit special, because variables can’t hold images. Here is the binding I use:


    if(typeof globalAA!=’undefined’){ item.setBoxBackground(globalAA,”nsf”,false);


    }


    return $aachange;

    ]]>

  12. Anonymous says:

    < ![CDATA[

    Lukas Morawietz OK Understood… I think. Lol


    What item do you use ? The music widget ?

    ]]>

  13. Anonymous says:

    < ![CDATA[

    Bruno-Isa LAMOUR-ARNOULD


     I use one text item for the title, album and artist. And one empty item for the album art.

    ]]>

  14. Anonymous says:

    < ![CDATA[

    Lukas Morawietz I’ll do, please remind me if I forget about it.

    ]]>

  15. Anonymous says:

    < ![CDATA[

    Done, don’t forget to manually activate the permission in the app settings on Android 6.

    ]]>

  16. Anonymous says:

    < ![CDATA[

    For anyone reading this looking for the permission apps…


    http://www.lightninglauncher.com/permissions//

    ]]>

  17. Anonymous says:

    < ![CDATA[

    Chris Chastain could be fine to set on this community header Pierre Hébert​

    ]]>

  18. Anonymous says:

    < ![CDATA[

    Bruno-Isa LAMOUR-ARNOULD


    did that

    ]]>

  19. Anonymous says:

    < ![CDATA[

    I thought it was there, I looked and it was! 🙂

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *