import flash.net.FileReferenceList;
02 |
03 | var playlist:Array = new Array(0); |
04 | var musik:Sound = new Sound(); |
05 | var angka:Number = new Number(0); |
06 | var fileRefList:FileReferenceList = new FileReferenceList(); |
07 | var listenerFileRefList:Object = new Object(); |
08 | var listHandler:Object = new Object(); |
09 |
10 | fscommand( "showmenu" , false ); |
11 | kanan_btn.onPress = kanan; |
12 | kiri_btn.onPress = kiri; |
13 | browse_btn.onPress = browseFile; |
14 | browse_btn.teks.text = "load" ; |
15 | kiri_btn.teks.text = "prev" ; |
16 | kanan_btn.teks.text = "next" ; |
17 | fileRefList.addListener(listenerFileRefList); |
18 | cmp_playlist.addEventListener( "change" , listHandler); |
19 | cmp_playlist.setStyle( "fontFamily" , "corbel" ); |
20 | cmp_playlist.setStyle( "fontSize" , "12" ); |
21 | tulisan_txt.text = "load file MP3 terlebih dulu..\n (maaf, di versi cupu ini, file MP3nya mesti sefolder sama aplikasinya)" ; |
22 |
23 | listHandler.change = function (evt:Object){ |
24 | if (angka != evt.target.selectedItem.data){ |
25 | angka = evt.target.selectedItem.data; |
26 | loadMusik(); |
27 | } |
28 | } |
29 |
30 | musik.onSoundComplete = function (){ |
31 | kanan(); |
32 | } |
33 |
34 | musik.onLoad = function (success:Boolean){ |
35 | if (success){ |
36 | musik.start(); |
37 | } |
38 | else { |
39 | tulisan_txt = "salah load file" ; |
40 | } |
41 | } |
42 |
43 | listenerFileRefList.onSelect = function (file:FileReferenceList){ |
44 | for ( var i = 0; i < file.fileList.length; i++){ |
45 | var filePilihan = file.fileList[i].name; |
46 | if (filePilihan.substr(-3, 3) == "mp3" ){ |
47 | cmp_playlist.addItem({label:filePilihan, data:playlist.length}); |
48 | playlist.push(filePilihan); |
49 | } |
50 | } |
51 | loadMusik(); |
52 | } |
53 |
54 | function browseFile(){ |
55 | fileRefList.browse([{description: "Ingat: file MP3 sefolder saja! (maklum versi cupu)" , extension: "*.mp3" }]); |
56 | } |
57 |
58 | function loadMusik(){ |
59 | musik.loadSound(playlist[angka], true ); |
60 | } |
61 |
62 | function kanan(){ |
63 | if (playlist.length < 1){ |
64 | tulisan_txt.text = "load filenya dulu woi..\n(tombolnya di bawah playlist)" ; |
65 | } |
66 | else { |
67 | angka += 1; |
68 | if (angka >= playlist.length){ |
69 | angka = 0; |
70 | } |
71 | loadMusik(); |
72 | } |
73 | } |
74 |
75 | function kiri(){ |
76 | if (playlist.length < 1){ |
77 | tulisan_txt.text = "load filenya dulu woi..\n(tombolnya di bawah playlist)" ; |
78 | } |
79 | else { |
80 | angka -= 1; |
81 | if (angka <= 0) { |
82 | angka = playlist.length - 1; |
83 | } |
84 | loadMusik(); |
85 | } |
86 | } |
87 |
88 | this .onEnterFrame= function (){ |
89 | var posisi:String = musik.position.toString(); |
90 | var durasi:String = musik.duration.toString(); |
91 | var artist:String = musik.id3.artist.toString(); |
92 | var judul:String = musik.id3.songname.toString(); |
93 | var menitPlaying:String = Math.floor(posisi/60000) + ":" + Math.round((posisi/1000)%60); |
94 | var menitTotal:String = Math.floor(durasi/60000) + ":" + Math.round((durasi/1000)%60); |
95 |
96 | if (playlist.length >= 1){ |
97 | tulisan_txt.text = artist + " - " + judul + "\n" + menitPlaying + " / " + menitTotal; |
98 | } |
99 | } |
Tidak ada komentar:
Posting Komentar