====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
script_music_metadata [2015/07/25 17:34] lm13 |
script_music_metadata [2016/06/28 12:12] (current) f43nd1r |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== About the script ====== | ====== About the script ====== | ||
* Purpose : This script collects metadata from music apps | * Purpose : This script collects metadata from music apps | ||
- | * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] | + | * Author : F43nd1r |
- | * Current Version : 1.0 | + | * Current Version : 2.1 |
* Link : https://plus.google.com/115366157037831519359/posts/4iVMvZKcUoc | * Link : https://plus.google.com/115366157037831519359/posts/4iVMvZKcUoc | ||
====== Changelog ====== | ====== Changelog ====== | ||
* Version 1.0 (25/7/2015): initial release in wiki | * Version 1.0 (25/7/2015): initial release in wiki | ||
+ | * Version 2.0 (24/5/2016): Rewrite using JavaAdapter | ||
+ | * Version 2.1 (26/5/1026): More players, albumcover support | ||
====== How to use the script ====== | ====== How to use the script ====== | ||
- | * Install the Multitool APK (Download in Repository) (you do not have to import the script) | ||
* Set this script in the load event of your desktop | * Set this script in the load event of your desktop | ||
- | * Add the intent actions of your music player in the first line of the script | + | * You can now use the following bindings at your will: $track, $album, $artist(, $albumcover, $aachanged) |
- | * You can now use the following bindings at your will: $track, $album, $artist | + | |
+ | ====== Runs with ====== | ||
+ | * Poweramp (with albumcover) | ||
+ | * Spotify | ||
+ | * AIMP | ||
+ | * Rocket Player | ||
+ | * Neutron | ||
+ | * BlackPlayer | ||
+ | * PlayerPro | ||
+ | * Samsung (can't test without Samsung device, but should work) | ||
+ | |||
+ | Other players may or may not work. | ||
====== Issues and Hints ====== | ====== Issues and Hints ====== | ||
Line 21: | Line 33: | ||
====== Script ====== | ====== Script ====== | ||
- | <sxh javascript;>var intents=["com.maxmpz.audioplayer.TRACK_CHANGED","com.maxmpz.audioplayer.STATUS_CHANGED","com.spotify.music.metadatachanged","com.android.music.metachanged"] | + | <sxh javascript;>var intents=["com.maxmpz.audioplayer.TRACK_CHANGED","com.maxmpz.audioplayer.STATUS_CHANGED","com.spotify.music.metadatachanged","com.maxmpz.audioplayer.AA_CHANGED","com.android.music.metachanged","com.jrtstudio.AnotherMusicPlayer.metachanged","com.tbig.playerpro.metachanged","com.tbig.playerprotrial.metachanged","com.sec.android.app.music.metachanged"]; |
+ | var defaultAlbumArt="/storage/sdcard0/download/default-albumart.png"; | ||
- | |||
- | LL.bindClass("java.lang.Runnable"); | ||
LL.bindClass("android.content.IntentFilter"); | LL.bindClass("android.content.IntentFilter"); | ||
- | LL.bindClass("java.lang.Class"); | ||
- | LL.bindClass("dalvik.system.PathClassLoader"); | ||
LL.bindClass("android.os.Bundle"); | LL.bindClass("android.os.Bundle"); | ||
+ | LL.bindClass("android.content.BroadcastReceiver"); | ||
+ | LL.bindClass("android.graphics.Bitmap"); | ||
+ | LL.bindClass("java.io.FileOutputStream"); | ||
- | var r=new Runnable(){ | + | var receiver=new JavaAdapter(BroadcastReceiver,{ |
- | run:function(){ | + | onReceive:function(c,i){ |
- | var i=receiver.getIntent(); | + | |
- | //LL.writeToLogFile("\n"+i,true); | + | |
var e=i.getExtras(); | var e=i.getExtras(); | ||
var v=LL.getVariables().edit(); | var v=LL.getVariables().edit(); | ||
Line 51: | Line 61: | ||
v.setString("artist",e.getString("artist")); | v.setString("artist",e.getString("artist")); | ||
} | } | ||
+ | } | ||
+ | if(e.containsKey("aaPath")){ | ||
+ | v. setString("albumart",e.getString("aaPath")); | ||
+ | v.setFloat("aachange",Math.random()); | ||
+ | } | ||
+ | else if(e.containsKey("aaBitmap")){ | ||
+ | var bmp=e.getParcelable("aaBitmap"); | ||
+ | var path=LL.getContext().getFilesDir()+"/albumart.png"; | ||
+ | var out=new FileOutputStream(path); | ||
+ | bmp.compress(Bitmap.CompressFormat.PNG,100,out); | ||
+ | out.close(); | ||
+ | v.setString("albumart",path); | ||
+ | v.setFloat("aachange",Math.random()); | ||
+ | } | ||
+ | else if(i.getAction().indexOf("AA_CHANGE")!=-1){ | ||
+ | v. setString("albumart",defaultAlbumArt); | ||
+ | v.setFloat("aachange",Math.random()); | ||
} | } | ||
v.commit(); | v.commit(); | ||
} | } | ||
- | }; | + | }); |
- | var c = LL.getContext(); | + | |
- | var apk = c.getPackageManager().getApplicationInfo("com.faendir.lightning_launcher.multitool",0).sourceDir; | + | |
- | var clsLoader=new PathClassLoader(apk,PathClassLoader.getSystemClassLoader()); | + | |
- | var cls=Class.forName("com.faendir.lightning_launcher.multitool.scripting.ScriptableBroadcastReceiver",true,clsLoader); | + | |
- | var receiver=cls.newInstance(); | + | |
- | receiver.setCallback(r); | + | |
var f = new IntentFilter(); | var f = new IntentFilter(); | ||
for(var i=0;i<intents.length;i++) | for(var i=0;i<intents.length;i++) | ||
f.addAction(intents[i]); | f.addAction(intents[i]); | ||
- | c.registerReceiver(receiver,f); | + | LL.getContext().registerReceiver(receiver,f); |
</sxh> | </sxh> |