-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscript_music_metadata_to_gid
57 lines (54 loc) · 1.96 KB
/
script_music_metadata_to_gid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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("android.content.IntentFilter");
LL.bindClass("android.os.Bundle");
LL.bindClass("android.content.BroadcastReceiver");
LL.bindClass("android.graphics.Bitmap");
LL.bindClass("java.io.FileOutputStream");
var receiver=new JavaAdapter(BroadcastReceiver,{
onReceive:function(c,i){
var e=i.getExtras();
var v=LL.getVariables().edit();
if(e.containsKey("track")){
var t=e.get("track");
if(track instanceof Bundle){
var title = t.getString("title");
var album = t.getString("album");
var artist = t.getString("artist");
}
else if(typeof t =="string"){
var track = t;
if(e.containsKey("album"))
var album = e.getString("album");
if(e.containsKey("artist"))
var 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();
var intent = new Intent('kg.serial.manager.send');
intent.putExtra('id','1234');
intent.putExtra('data', artist + '<br/> ' + track);
LL.getContext().sendBroadcast(intent);
}
});
var f = new IntentFilter();
for(var i=0;i<intents.length;i++)
f.addAction(intents[i]);
LL.getContext().registerReceiver(receiver,f);