aboutsummaryrefslogtreecommitdiff
path: root/Src/resources/skins/Big Bento/scripts/seek.m
blob: f5d5b34828f6bc0c057f33e650339947ea888153 (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
/*---------------------------------------------------
-----------------------------------------------------
Filename:	seek.m
Version:	1.2

Type:		maki
Date:		23. Jul. 2007 - 22:52 
Author:		Martin Poehlmann aka Deimos
E-Mail:		martin@skinconsortium.com
Internet:	www.skinconsortium.com
		www.martin.deimos.de.vu

Note:		This script is based on seek.m
		from Winamp Modern
-----------------------------------------------------
---------------------------------------------------*/

#include <lib/std.mi>

Global Group frameGroup;
Global Slider Seeker, SeekerBehind;
Global Int Seeking;
Global GuiObject SongTicker;
Global GuiObject progressBar;

System.onScriptLoaded()
{
	frameGroup = system.getScriptGroup();
	Seeker = frameGroup.findObject("seeker.ghost");
	SeekerBehind = frameGroup.findObject("seeker.ghost");
	progressBar = frameGroup.findObject("progressbar");
	SongTicker = frameGroup.getParentLayout().findObject("songticker");

	progressBar.hide();
progressBar.show();

	if (getStatus() == 0 || !seeker.isvisible())
	{
		progressBar.hide();
	}
}

Seeker.onSetPosition(int p) {
	if (seeking) {
		Float f;
		f = p;
		f = f / 255 * 100;
		Float len = getPlayItemLength();
		if (len != 0) {
			int np = len * f / 100;
			SongTicker.sendAction
			(
				"showinfo",
				translate("Seek") + ": " + integerToTime(np) + "/" + integerToTime(len) + " (" + integerToString(f) + "%) ",
				0, 0, 0, 0
			);
		}
	}
}

/** Hehe, this is the best trick i figured out to indicate if we have a stream */

Seeker.onSetVisible (Boolean onoff)
{
	if (onoff)
	{
		progressBar.show();
	}
	else
	{
		progressBar.hide();
	}
}

Seeker.onLeftButtonDown(int x, int y) {
	seeking = 1;
	Seeker.setAlpha(128);
	SeekerBehind.show();
}

Seeker.onLeftButtonUp(int x, int y) {
	seeking = 0;
	Seeker.setAlpha(255);
	SeekerBehind.hide();
	SongTicker.sendAction("cancelinfo", "", 0, 0, 0, 0);
}

Seeker.onSetFinalPosition(int p) {
	SongTicker.sendAction("cancelinfo", "", 0, 0, 0, 0);
}