Comment désactiver la fonction de lecture automatique de la playlist ?

Comment désactiver la fonction de lecture automatique de la playlist ? - Flash/ActionScript - Programmation

Marsh Posté le 11-08-2012 à 18:10:03    


Bonjour,
 
Je cherche dans le code la fonction qui permet de désactiver la lecture auto de la playlist des fichiers mp3 d'un lecteur si vous pouviez m'indiquer la ligne en question voir le code je galère pas possible merci
 
 

Code :
  1. // Create Sound Object
  2. var mp3_player:Sound = new Sound(this);
  3. // Set Starting Volume
  4. var player_volume:Number = 75;
  5. // Shuffle playlist mode on /off
  6. var shuffle = false;
  7. // Create Playlist Array
  8. var play_list:Array = [];
  9. // Song position
  10. var current_position:Number = 0;
  11. // Starting Playing Song Number
  12. var current_song_number:Number = 0;
  13. // Starting Show Playlist on / off
  14. var play_list_open:Boolean = false;
  15. // Now playing or Stop Boolean Value
  16. var playing_status:Boolean = false;
  17. var drag_start:Boolean = false;
  18. var move_stop:Boolean = false;
  19. // Create mask for play list
  20. play_list_mc.setMask(mask_mc);
  21. play_list_mc._y = play_list_mc._y-play_list_mc._height;
  22. // Player Mute on / off
  23. var mute:Boolean = false;
  24. // if shuffle mode on, goto shuffle button "on"
  25. var goto_shuffle:String = shuffle ? "shuffle_on" : "shuffle_off";
  26. shuffle_mc.gotoAndStop(goto_shuffle);
  27. // Create playlist XML
  28. var play_list_xml:XML = new XML();
  29. play_list_xml.ignoreWhite = true;
  30. play_list_xml.onLoad = function(load_status:Boolean):Void  {
  31. var nodes:Array = this.firstChild.childNodes;
  32. play_list_length = nodes.length;
  33. for (var i = 0; i<nodes.length; i++) {
  34.   // add all song information to playlist array
  35.   play_list.push({url:nodes[i].attributes.url, artist:nodes[i].attributes.artist, track:nodes[i].attributes.track});
  36. }
  37. // goto duplicate songname on playlist function
  38. create_play_list();
  39. if (shuffle) {
  40.   // if shuffle mode on, goto select random song number function
  41.   shuffle_playlist(current_song_number);
  42. } else {
  43.   // if shuffle mode off, goto and play ordinary song
  44.   play_song(current_song_number);
  45. }
  46. };
  47. // load xml file
  48. play_list_xml.load("xml/songs.xml" );
  49. // Define duplicate song information's text field in playlist function
  50. create_play_list = function () {
  51. var song_name = this.play_list_mc.scroller_mc.mc.song_name_mc.text_mc;
  52. // add first text field song name info
  53. song_name.name_txt.text = play_list[0].track+" - "+play_list[0].artist;
  54. // first song number
  55. song_name.number_txt.text = "01.";
  56. // define song id
  57. this.play_list_mc.scroller_mc.mc.song_name_mc.color_bar_mc.id = 0;
  58. for (i=2; i<play_list_length+1; i++) {
  59.   //  duplicate song name text field
  60.   var song_name = this.play_list_mc.scroller_mc.mc.song_name_mc.duplicateMovieClip("song_name"+i, i);
  61.   // Define song number id
  62.   song_name.color_bar_mc.id = i-1;
  63.   // song name y position
  64.   song_name._y = this.play_list_mc.scroller_mc.mc.song_name_mc._y+this.play_list_mc.scroller_mc.mc.song_name_mc._height*(i-1);
  65.   // add song information to dynamic text field
  66.   song_name.text_mc.name_txt.text = play_list[i-1].track+" - "+play_list[i-1].artist;
  67.   // add song number
  68.   if (i<10) {
  69.    song_name.text_mc.number_txt.text = "0"+String(i)+".";
  70.   } else {
  71.    song_name.text_mc.number_txt.text = String(i)+".";
  72.   }
  73. }
  74. // open and show playlist
  75. if (play_list_open) {
  76.   var distance_y = 155;
  77.   show_playlist_mc.gotoAndStop("close" );
  78.   // playlist move down or up function
  79.   content_move(play_list_mc, distance_y, 0.3);
  80. }
  81. };
  82. // Define Play Song Function. This function is for load and play specific song number
  83. play_song = function (song_number) {
  84. // stop old song
  85. mp3_player.stop();
  86. // set to start position
  87. mp3_player.start(0, 1);
  88. // start load song via streaming
  89. mp3_player.loadSound(play_list[song_number].url, true);
  90. // set song volume
  91. set_volume(player_volume);
  92. // goto play / pause button to pause mode
  93. play_pause_mc.gotoAndStop("pause" );
  94. // set status to now playing
  95. playing_status = true;
  96. // show song name info text
  97. display_song_name_mc.title_txt.text = play_list[song_number].track+" - "+play_list[song_number].artist;
  98. // create time loop for display time
  99. timer = setInterval(display_time, 1000);
  100. };
  101. // if play/pause button over, call this function
  102. play_pause_mc.onRollOver = function() {
  103. if (playing_status) {
  104.   play_pause_mc.gotoAndStop("pause_over" );
  105. } else {
  106.   play_pause_mc.gotoAndStop("play_over" );
  107. }
  108. };
  109. // if play/pause button Rollover, call this function
  110. play_pause_mc.onRollOut = function() {
  111. if (playing_status) {
  112.   play_pause_mc.gotoAndStop("pause" );
  113. } else {
  114.   play_pause_mc.gotoAndStop("play" );
  115. }
  116. };
  117. // if play/pause button pressed, call this function
  118. play_pause_mc.onRelease = function() {
  119. // controll playing status
  120. if (playing_status) {
  121.   // if status is playing, goto sound equalizer animation pause section.
  122.   sound_animation_mc.gotoAndPlay("pause" );
  123.   // save current song position
  124.   current_position = mp3_player.position;
  125.   // stop song
  126.   mp3_player.stop();
  127.   // set current song status "stop"
  128.   playing_status = false;
  129.   // goto play/pause button "play"
  130.   play_pause_mc.gotoAndStop("play_over" );
  131. } else {
  132.   // if current status is pause, goto sound equalizer animation "play" section.
  133.   sound_animation_mc.gotoAndPlay("play" );
  134.   // continue play from paused position
  135.   mp3_player.start(current_position/1000, 1);
  136.   // set status to now playing
  137.   playing_status = true;
  138.   // goto play/pause button to "pause"
  139.   play_pause_mc.gotoAndStop("pause_over" );
  140. }
  141. };
  142. // if "play next song" button over, call this function
  143. next_mc.onRollOver = function() {
  144. next_mc.gotoAndStop("next_over" );
  145. };
  146. // if "play next song" button rollout, call this function
  147. next_mc.onRollOut = function() {
  148. next_mc.gotoAndStop("next" );
  149. };
  150. // if "play next song" button pressed, call this function
  151. next_mc.onRelease = function() {
  152. sound_animation_mc.gotoAndPlay("play" );
  153. // call play next song function
  154. play_next();
  155. };
  156. // show current song time and total song time
  157. display_time = function () {
  158. // get current song time (millisecond)
  159. var current_time:Number = mp3_player.position/1000;
  160. // get total song time (millisecond)
  161. var total_time:Number = ((mp3_player.duration/((mp3_player.getBytesLoaded()/mp3_player.getBytesTotal())*100))*100)/1000;
  162. // convert millisecond to second and add zero for display
  163. if (current_time<total_time) {
  164.   var current_time_minute:Number = add_zero(Math.floor(current_time/60));
  165.   var current_time_second:Number = add_zero(Math.floor(current_time%60));
  166.   var duration_minute:Number = add_zero(Math.floor(total_time/60));
  167.   var duration_second:Number = add_zero(Math.floor(total_time%60));
  168.   // show playing time and total time
  169.   time_txt.text = current_time_minute+":"+current_time_second+" / "+duration_minute+":"+duration_second;
  170. }
  171. // if song position arrive to end of song
  172. if (Math.floor(current_time) == Math.floor(total_time)) {
  173.   if (current_time<>"0" ) {
  174.    // if shuffle mode on
  175.    if (shuffle) {
  176.         // play random song
  177.         shuffle_playlist(current_song_number);
  178.    } else {
  179.         // play ordinary song
  180.         play_next();
  181.    }
  182.    clearInterval(timer);
  183.   }
  184. }
  185. };
  186. // add zero to time function
  187. add_zero = function (num:Number):String {
  188. return String(num).length == 1 ? "0"+num : num;
  189. };
  190. // Define play next song function
  191. play_next = function () {
  192. // check end of playlist
  193. if (current_song_number<play_list.length-1) {
  194.   // next song number
  195.   current_song_number++;
  196. } else {
  197.   // set song number to first song
  198.   current_song_number = 0;
  199. }
  200. // call play song function
  201. play_song(current_song_number);
  202. };
  203. // Define random song number function
  204. shuffle_playlist = function (old_song_number) {
  205. var new_song_number:Number = Math.floor(Math.random()*play_list.length);
  206. // check old song number diffrent from new song number
  207. while (new_song_number == old_song_number) {
  208.   new_song_number = Math.floor(Math.random()*play_list.length);
  209. }
  210. current_song_number = new_song_number;
  211. // call play song function
  212. play_song(new_song_number);
  213. };
  214. // calculate loader bar percent function
  215. loader_status = function () {
  216. // get loaded info
  217. var amountLoaded:Number = mp3_player.getBytesLoaded()/mp3_player.getBytesTotal();
  218. // set loader bar width
  219. loader.loadbar._width = Math.floor(amountLoaded*100);
  220. // get total song length.
  221. trueDuration = Math.ceil((mp3_player.duration/((mp3_player.getBytesLoaded()/mp3_player.getBytesTotal())*100))*100);
  222. if (drag_start == false) {
  223.   // set position loader bar scrub
  224.   loader.scrub._x = (mp3_player.position/trueDuration)*100;
  225. }
  226. };
  227. // create empty movie clip for loader bar scrub
  228. this.createEmptyMovieClip("vFrame", this.getNextHighestDepth());
  229. vFrame.onEnterFrame = loader_status;
  230. // when press to scrub, start drag
  231. loader.scrub.onPress = function() {
  232. drag_start = true;
  233. this.startDrag(false, 0, this._y, 100, this._y);
  234. };
  235. // when release scrub, stop dragging and calculate new song position
  236. loader.scrub.onRelease = loader.scrub.onReleaseOutside=function () {
  237. loader.scrub.gotoAndStop(1);
  238. drag_start = false;
  239. mp3_player.stop();
  240. // get totoal time
  241. trueDuration = Math.ceil((mp3_player.duration/((mp3_player.getBytesLoaded()/mp3_player.getBytesTotal())*100))*100);
  242. // calculate new song position
  243. current_position = Math.floor(((loader.scrub._x/100)*trueDuration)/1000);
  244. // start song from new position
  245. mp3_player.start(current_position, 1);
  246. this.stopDrag();
  247. };
  248. loader.scrub.onRollOver = function() {
  249. loader.scrub.gotoAndStop(2);
  250. };
  251. loader.scrub.onRollOut = function() {
  252. loader.scrub.gotoAndStop(1);
  253. };
  254. // when over the show playlist button
  255. show_playlist_mc.onRollOver = function() {
  256. if (play_list_open == false) {
  257.   show_playlist_mc.gotoAndStop("open_over" );
  258. } else {
  259.   show_playlist_mc.gotoAndStop("close_over" );
  260. }
  261. };
  262. // when rollout the show playlist button
  263. show_playlist_mc.onRollOut = function() {
  264. if (play_list_open == false) {
  265.   show_playlist_mc.gotoAndStop("open" );
  266. } else {
  267.   show_playlist_mc.gotoAndStop("close" );
  268. }
  269. };
  270. // when pressed the show playlist button
  271. show_playlist_mc.onRelease = function() {
  272. if (move_stop == false) {
  273.   if (play_list_open == false) {
  274.    // playlist movie clip move distance (goto down)
  275.    var distance_y = 155;
  276.    show_playlist_mc.gotoAndStop("close_over" );
  277.   } else {
  278.    // playlist movie clip move distance (goto up)
  279.    var distance_y = -155;
  280.    show_playlist_mc.gotoAndStop("open_over" );
  281.   }
  282.   // set reverse boolean value
  283.   play_list_open = !play_list_open;
  284.   // call playlist move function..(0.3 = move speed)
  285.   content_move(play_list_mc, distance_y, 0.3);
  286. }
  287. };
  288. // Define Playlist Box (content) main scroller function. (target MC, scroll distance, scroll speed)
  289. function content_move(target:MovieClip, scroll_distance_y:Number, speed:Number) {
  290. move_stop = true;
  291. current_y = target._y;
  292. target.onEnterFrame = function() {
  293.   if (scroll_distance_y<0) {
  294.    current_scroll_distance = Math.floor(((scroll_distance_y+current_y)-target._y)*speed);
  295.   } else {
  296.    current_scroll_distance = Math.ceil(((scroll_distance_y+current_y)-target._y)*speed);
  297.   }
  298.   if (target._y == scroll_distance_y+current_y) {
  299.    move_stop = false;
  300.    delete target.onEnterFrame;
  301.   }
  302.   target._y += current_scroll_distance;
  303. };
  304. }
  305. // when pressed the mute button
  306. mute_mc.onRelease = function() {
  307. if (mute == false) {
  308.   old_volume = player_volume;
  309.   player_volume = 0;
  310.   set_volume(player_volume);
  311.   mute = true;
  312.   mute_mc.gotoAndStop("mute_on_over" );
  313. } else {
  314.   player_volume = old_volume;
  315.   set_volume(player_volume);
  316.   mute = false;
  317.   mute_mc.gotoAndStop("mute_off_over" );
  318. }
  319. };
  320. mute_mc.onRollOver = function() {
  321. if (mute == false) {
  322.   mute_mc.gotoAndStop("mute_off_over" );
  323. } else {
  324.   mute_mc.gotoAndStop("mute_on_over" );
  325. }
  326. };
  327. mute_mc.onRollOut = function() {
  328. if (mute == false) {
  329.   mute_mc.gotoAndStop("mute_off" );
  330. } else {
  331.   mute_mc.gotoAndStop("mute_on" );
  332. }
  333. };
  334. set_volume = function (player_volume) {
  335. mp3_player.setVolume(player_volume);
  336. volume_control_mc.volume_bar_mc._width = volume_control_mc.slider_mc._x=(player_volume/100)*100;
  337. };
  338. shuffle_mc.onRollOver = function() {
  339. var goto_shuffle:String = shuffle ? "shuffle_on_over" : "shuffle_off_over";
  340. shuffle_mc.gotoAndStop(goto_shuffle);
  341. };
  342. shuffle_mc.onRollOut = function() {
  343. var goto_shuffle:String = shuffle ? "shuffle_on" : "shuffle_off";
  344. shuffle_mc.gotoAndStop(goto_shuffle);
  345. };
  346. shuffle_mc.onRelease = function() {
  347. shuffle = !shuffle;
  348. var goto_shuffle:String = shuffle ? "shuffle_on" : "shuffle_off";
  349. shuffle_mc.gotoAndStop(goto_shuffle);
  350. };

Reply

Marsh Posté le 11-08-2012 à 18:10:03   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed