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.
]]>(Next Post) Title »
< ![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);
]]>
< ![CDATA[
Woo hoo!
]]>
< ![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.
]]>
< ![CDATA[
We appreciate your craziness 🙂
]]>
< ![CDATA[
fantastic! does this work with youtube (since it doesn’t play media files but rather video streams)?
]]>
< ![CDATA[
Wern-Yuen Tan yes! (thumbnail and title)
]]>
< ![CDATA[
Wow, is it making LLx Music widget ?
]]>
< ![CDATA[
This version definetly has a memory leak. → *Not for everyday usage!*Memory leak fixed]]>
< ![CDATA[
Pierre Hébert could you create a package for this permission, so non-root users can use this script too?
]]>
< ![CDATA[
Lukas Morawietz please explain how to use. I’m running from the desktop : nothing.
From a music widget : nothing
]]>
< ![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;
]]>
< ![CDATA[
Lukas Morawietz OK Understood… I think. Lol
What item do you use ? The music widget ?
]]>
< ![CDATA[
Bruno-Isa LAMOUR-ARNOULD
I use one text item for the title, album and artist. And one empty item for the album art.
]]>
< ![CDATA[
Lukas Morawietz I’ll do, please remind me if I forget about it.
]]>
< ![CDATA[
Done, don’t forget to manually activate the permission in the app settings on Android 6.
]]>
< ![CDATA[
For anyone reading this looking for the permission apps…
http://www.lightninglauncher.com/permissions//
]]>
< ![CDATA[
Chris Chastain could be fine to set on this community header Pierre Hébert
]]>
< ![CDATA[
Bruno-Isa LAMOUR-ARNOULD
did that
]]>
< ![CDATA[
I thought it was there, I looked and it was! 🙂
]]>