-
Notifications
You must be signed in to change notification settings - Fork 0
/
musicplayer
315 lines (313 loc) · 8.61 KB
/
musicplayer
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
musicPause.enabled = false;
musicPlay.enabled = true;
var state1 = new Boolean();
var firstime = new Boolean();
var musicPlaying = new Boolean();
var hitPlay = new Boolean();
state1 = false;
musicPlaying = false;
hitPlay = false;
firstime = true;
var musakVolume2 = new Number();
musakVolume2 = 0;
/************************************BUTTON FUNCTIONS***********************************/
this.musicPlay.onRollOver = function() {
if (!musicPlaying) {
musicPlay.gotoAndStop(2);
} else if (hitPlay) {
musicPlay.gotoAndStop(2);
} else {
musicPlay.gotoAndStop(2);
}
};
this.musicPlay.onRollOut = function() {
if (!musicPlaying) {
musicPlay.gotoAndStop(1);
} else if (hitPlay) {
musicPlay.gotoAndStop(2);
} else {
musicPlay.gotoAndStop(2);
}
};
this.musicPlay.onRelease = function() {
if (firstime) {
firstime = false;
} else {
_parent.globalNum = 1;
}
musicPause.enabled = true;
musicPause.gotoAndStop(1);
hitPlay = true;
playMusak();
if (musicPlay.enabled) {
musicPlay.gotoAndStop(2);
//musicPause.gotoAndStop(1);
musicPlay.enabled = false;
}
if (state1) {
musicPlay.enabled = true;
musicPause.gotoAndStop(1);
musicPause.enabled = false;
} else {
musicPause.enabled = true;
musicPause.gotoAndStop(1);
state1 = false;
}
};
/****************************************END BUTTON FUNCTIONS*******************************/
/*********************************************MUSIC PLAYER FUNCTIONS************************************/
//----------------<sound initialization>-------------------\\
var curTrackNum:Number = 90;
var bgMusak:Sound;
var pausePosition = new Number();
var fastForwardHold = new Number();
var pausePressed = new Boolean();
var nextBtnPressed = new Boolean();
pausePressed = true;
nextBtnPressed = false;
musicPause.enabled = false;
// autosize some text fields
//this.trackInfo.autoSize = "left";
this.streamedBar._visible = false;
this.playedBar._visible = false;
// load the track info vars
var myMusicLv:LoadVars = new LoadVars();
myMusicLv.load("vars/track_info.txt");
musicPrev.tabEnabled = false;
musicNext.tabEnabled = false;
musicPause.tabEnabled = false;
musicPlay.tabEnabled = false;
//---------------------sound setup--------------------------------//
this.musicPause.onRelease = function() {
hitPlay = false;
musicPlaying = false;
musicPause.gotoAndStop(2);
musicPause.enabled = false;
musicPlay.enabled = true;
musicPlay.gotoAndStop(1);
state1 = false;
if (pausePressed) {
pausePosition = bgMusak.position/1000;
fastForwardBtn.enabled = false;
rewindBtn.enabled = false;
buttonInfo.text = "";
bgMusak.stop();
pausePressed = false;
}
// end if
};
// end function
function stopMusak() {
bgMusak.stop();
delete bgMusak;
}
// end function
function playMusak() {
if (pausePressed || (!pausePressed && !musicPause.enabled && nextBtnPressed)) {
if (firstime) {
firstime = false;
} else {
_parent.globalNum = 1;
}
_root.randomFunc();
//trace(_root.globalNum);
//trace(firstime);
musicPlaying = true;
picLoadAnim.gotoAndPlay(39);
trace(picLoadAnim);
nextBtnPressed = false;
musicPause.enabled = true;
streamedBar._visible = true;
playedBar._visible = true;
playedBar._xscale = 0;
streamedBar._xscale = 0;
bgMusak = new Sound();
bgMusak.onSoundComplete = function() {
if (curTrackNum == (myMusicLv.totalTracks-1)+90) {
curTrackNum = 90;
} else {
curTrackNum++;
}
playMusak();
};
// end function
bgMusak.onID3 = function() {
textScroll.scrollee.SetText(bgMusak.id3.TIT2+" ", true);
};
// end function
bgMusak.onLoad = function(success) {
if (!success) {
trackInfo.text = "Failed to load track.";
}
};
bgMusak.loadSound("mp3s/mp3-"+curTrackNum+".mp3", true);
onEnterFrame = function () {
var trackDlProg:Number = bgMusak.getBytesLoaded()/1000;
var trackDlTotal:Number = bgMusak.getBytesTotal()/1000;
var trackDlPercent:Number = (trackDlProg/trackDlTotal)*100;
var trackDlDuration:Number = (bgMusak.duration/trackDlPercent)*100;
streamedBar._xscale = (trackDlProg/trackDlTotal)*100;
//trackDlPercent;
playedBar._xscale = (bgMusak.position/trackDlDuration)*100;
};
// end function
playedBar.onEnterFrame = function() {
bgMusak.setVolume(musakVolume/2);
musakVolume = -(musakVolumeMC.musakVolumeSliderMC._x*2);
musakVolume2 = -(musakVolumeMC.musakVolumeSliderMC._x*2);
// put Kilobytes loaded and total and put them into variables
var trackDlProg:Number = _root.bgMusak.getBytesLoaded()/1000;
var trackDlTotal:Number = _root.bgMusak.getBytesTotal()/1000;
var trackDlPercent:Number = Math.round((trackDlProg/trackDlTotal)*100);
var trackDlDuration:Number = Math.round((bgMusak.duration/trackDlPercent)*100);
musakProgBar.progMaskContainer.progMask._width = trackDlPercent+9;
musakProgBar.musakProg._x = Math.round((_root.bgMusak.position/trackDlDuration)*100);
};
//end function
} else {
if (firstime) {
firstime = false;
} else {
_parent.globalNum = 1;
}
fastForwardBtn.enabled = true;
rewindBtn.enabled = true;
pausePressed = true;
musicPause.enabled = true;
bgMusak.start(pausePosition);
_root.musicPause.gotoAndStop(1);
}
// end if
// end else
_root.musicPause.gotoAndStop(1);
}
// end playMusak
//--------------------/sound setup--------------------------------//
//----------------<next track>-------------------\\
this.musicNext.onRelease = function() {
musicNext.gotoAndStop(2);
};
this.musicNext.onRollOver = function() {
musicNext.gotoAndStop(2);
};
this.musicNext.onRollOut = function() {
musicNext.gotoAndStop(1);
};
this.musicNext.onPress = function() {
musicNext.gotoAndStop(1);
if (!musicPause.enabled) {
musicPlay.gotoAndStop(2);
if (state1) {
musicPlay.enabled = true;
musicPause.enabled = false;
} else {
musicPause.enabled = true;
state1 = false;
}
}
//////////////////////////////////////////////
trackInfo.text = "";
if (curTrackNum == (myMusicLv.totalTracks-1)+90) {
curTrackNum = 90;
} else {
curTrackNum++;
}
nextBtnPressed = true;
pausePressed = true;
musicPause.enabled = true;
musicPause.gotoAndStop(1);
stopMusak();
playMusak();
};
////////////////end musicNext Function
//----------------</next track>-------------------\\
//----------------<previous track>-------------------\\
this.musicPrev.onRelease = function() {
musicPrev.gotoAndStop(2);
};
this.musicPrev.onRollOver = function() {
musicPrev.gotoAndStop(2);
};
this.musicPrev.onRollOut = function() {
musicPrev.gotoAndStop(1);
};
this.musicPrev.onPress = function() {
musicPrev.gotoAndPlay(2);
if (!musicPause.enabled) {
musicPlay.gotoAndStop(2);
musicPlay.enabled = false;
if (state1) {
musicPlay.enabled = true;
musicPause.enabled = false;
} else {
musicPause.enabled = true;
state1 = false;
}
}
///////////////////////
trackInfo.text = "";
if (curTrackNum == 90) {
curTrackNum = (myMusicLv.totalTracks-1)+90;
} else {
curTrackNum--;
}
nextBtnPressed = true;
pausePressed = true;
musicPause.enabled = true;
musicPause.gotoAndStop(1);
stopMusak();
playMusak();
};
///////end musicPrev Function
//----------------</previous track>-------------------\\
//----------------pause Button----------------------\\
this.musicPause.onRollOver = function() {
musicPause.gotoAndStop(2);
};
this.musicPause.onRollOut = function() {
musicPause.gotoAndStop(1);
};
//----------------/pause Button----------------------\\
//----------------</sound initialization>-------------------\\
//----------------<volume control>-------------------\\
// initialize some volume control settings
var musakVolume:Number = 140;
this.musakVolumeMC._visible = true;
// Set Volume to start at what musakVolume is at
this.musakVolumeMC.musakVolumeSliderMC._x = musakVolume/2;
// set what should happen when the volume slider is pressed, released, or released outside
this.musakVolumeMC.musakVolumeSliderMC.onPress = function() {
startDrag(this, true, 0, 0, 120, 0);
};
this.musakVolumeMC.musakVolumeSliderMC.onRelease = function() {
stopDrag();
};
this.musakVolumeMC.musakVolumeSliderMC.onReleaseOutside = function() {
stopDrag();
};
//----------------</volume control>-------------------\\
init();
function init() {
musicPause.enabled = true;
musicPause.gotoAndStop(1);
hitPlay = true;
pausePressed = true;
_level0.mPlayer.mainPicLoad.loadPic("soon.swf");
_root.mPlayer.picLoadAnim.gotoAndPlay(39);
trace(picLoadAnim);
playMusak();
if (musicPlay.enabled) {
musicPlay.gotoAndStop(2);
musicPlay.enabled = false;
}
if (state1) {
musicPlay.enabled = true;
musicPause.gotoAndStop(1);
musicPause.enabled = false;
} else {
musicPause.enabled = true;
musicPause.gotoAndStop(1);
state1 = false;
}
}
picLoadAnim.gotoAndPlay(39);