aboutsummaryrefslogtreecommitdiff
path: root/Src/resources/skins/Big Bento/scripts/albumart.m
blob: f188973dfae98a2198b09950dd8bfcb2fe1e2588 (plain) (blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*---------------------------------------------------
-----------------------------------------------------
Filename:	albumart.m
Version:	1.1

Type:		maki
Date:		20. Sep. 2007 - 16:54 
Author:		Martin Poehlmann aka Deimos
E-Mail:		martin@skinconsortium.com
Internet:	www.skinconsortium.com
		www.martin.deimos.de.vu
-----------------------------------------------------
---------------------------------------------------*/

#include <lib/std.mi>
#include <lib/com/songinfo.m>

#define WEBCOVER_SHOUTCAST "winamp.cover.shoutcast"

Function loadFileInfo();
//Function loadPlaylistArtWork();

Global Int plArtRetries = 0;
Global Group scriptGroup;
Global AlbumArtLayer l_albumart;
Global String notfoundImage = "winamp.cover.notfound.xxl";

System.onScriptLoaded ()
{
	scriptGroup = getScriptGroup();
	l_albumart = scriptGroup.findObject(getToken(getParam(), ",", 0));
	notfoundImage = getToken(getParam(), ",", 1);
	loadFileInfo();
}

l_albumart.onRightButtonDown (int x, int y)
{
	popupmenu p = new popupmenu;

	p.addCommand("Refresh Album Art", 1, 0, 0);
	String path = getPath(getPlayItemMetaDataString("filename"));
	if(path != "")
	{
		p.addCommand("Open Folder", 2, 0, 0);
	}

	int result = p.popatmouse();
	delete p;

	if (result == 1)
	{
		l_albumart.refresh();
	}
	else if (result == 2)
	{
		if(path != "")
		{
			System.navigateUrl(path);
		}
		else
		{
			String url = getPlayItemMetaDataString("streamurl");
			if(url != "")
			{
				System.navigateUrl(url);
			}
		}
	}
}

l_albumart.onLeftButtonDblClk (int x, int y)
{
	String path = getPath(getPlayItemMetaDataString("filename"));
	if(path != "")
	{
		System.navigateUrl(path);
	}
	else
	{
		String url = getPlayItemMetaDataString("streamurl");
		if(url != "")
		{
			System.navigateUrl(url);
		}
	}
}

loadFileInfo ()
{
	songinfo_reload(); // refresh vars
	plArtRetries = 0;
	l_albumart.setXMLParam("notfoundImage", notfoundImage);

	//debugInt(songinfo_isStream);
	if (songinfo_isStream)
	{
		// setCover either from a supplied url or from in-stream artwork or default to a generic image
		if (songinfo_streamAlbumArt != "")
		{
			l_albumart.setXMLParam("image", songinfo_streamAlbumArt);
			l_albumart.setXMLParam("notfoundImage", notfoundImage);
		}

		if(songinfo_streamType == SONGINFO_STREAMTYPE_SHOUTCAST || songinfo_streamType == SONGINFO_STREAMTYPE_SHOUTCAST2)
		{
			if(songinfo_streamType == SONGINFO_STREAMTYPE_SHOUTCAST2)
			{
				if(l_albumart.isInvalid() && plArtRetries < 5)
				{
					if(!plArtRetries)
					{
						l_albumart.setXMLParam("notfoundImage", WEBCOVER_SHOUTCAST);
					}
					plArtRetries += 1;
					l_albumart.refresh();
				}
			}
			else
			{
				l_albumart.setXMLParam("notfoundImage", WEBCOVER_SHOUTCAST);
			}
		}
	}
}

// Hide branding of we start playback
System.onPlay ()
{
	loadFileInfo();
}

System.onTitleChange (String newtitle)
{
	loadFileInfo();
}