Didou19999 |
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 :
- // Create Sound Object
- var mp3_player:Sound = new Sound(this);
- // Set Starting Volume
- var player_volume:Number = 75;
- // Shuffle playlist mode on /off
- var shuffle = false;
- // Create Playlist Array
- var play_list:Array = [];
- // Song position
- var current_position:Number = 0;
- // Starting Playing Song Number
- var current_song_number:Number = 0;
- // Starting Show Playlist on / off
- var play_list_open:Boolean = false;
- // Now playing or Stop Boolean Value
- var playing_status:Boolean = false;
- var drag_start:Boolean = false;
- var move_stop:Boolean = false;
- // Create mask for play list
- play_list_mc.setMask(mask_mc);
- play_list_mc._y = play_list_mc._y-play_list_mc._height;
- // Player Mute on / off
- var mute:Boolean = false;
- // if shuffle mode on, goto shuffle button "on"
- var goto_shuffle:String = shuffle ? "shuffle_on" : "shuffle_off";
- shuffle_mc.gotoAndStop(goto_shuffle);
- // Create playlist XML
- var play_list_xml:XML = new XML();
- play_list_xml.ignoreWhite = true;
- play_list_xml.onLoad = function(load_status:Boolean):Void {
- var nodes:Array = this.firstChild.childNodes;
- play_list_length = nodes.length;
- for (var i = 0; i<nodes.length; i++) {
- // add all song information to playlist array
- play_list.push({url:nodes[i].attributes.url, artist:nodes[i].attributes.artist, track:nodes[i].attributes.track});
- }
- // goto duplicate songname on playlist function
- create_play_list();
- if (shuffle) {
- // if shuffle mode on, goto select random song number function
- shuffle_playlist(current_song_number);
- } else {
- // if shuffle mode off, goto and play ordinary song
- play_song(current_song_number);
- }
- };
- // load xml file
- play_list_xml.load("xml/songs.xml" );
- // Define duplicate song information's text field in playlist function
- create_play_list = function () {
- var song_name = this.play_list_mc.scroller_mc.mc.song_name_mc.text_mc;
- // add first text field song name info
- song_name.name_txt.text = play_list[0].track+" - "+play_list[0].artist;
- // first song number
- song_name.number_txt.text = "01.";
- // define song id
- this.play_list_mc.scroller_mc.mc.song_name_mc.color_bar_mc.id = 0;
- for (i=2; i<play_list_length+1; i++) {
- // duplicate song name text field
- var song_name = this.play_list_mc.scroller_mc.mc.song_name_mc.duplicateMovieClip("song_name"+i, i);
- // Define song number id
- song_name.color_bar_mc.id = i-1;
- // song name y position
- 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);
- // add song information to dynamic text field
- song_name.text_mc.name_txt.text = play_list[i-1].track+" - "+play_list[i-1].artist;
- // add song number
- if (i<10) {
- song_name.text_mc.number_txt.text = "0"+String(i)+".";
- } else {
- song_name.text_mc.number_txt.text = String(i)+".";
- }
- }
- // open and show playlist
- if (play_list_open) {
- var distance_y = 155;
- show_playlist_mc.gotoAndStop("close" );
- // playlist move down or up function
- content_move(play_list_mc, distance_y, 0.3);
- }
- };
- // Define Play Song Function. This function is for load and play specific song number
- play_song = function (song_number) {
- // stop old song
- mp3_player.stop();
- // set to start position
- mp3_player.start(0, 1);
- // start load song via streaming
- mp3_player.loadSound(play_list[song_number].url, true);
- // set song volume
- set_volume(player_volume);
- // goto play / pause button to pause mode
- play_pause_mc.gotoAndStop("pause" );
- // set status to now playing
- playing_status = true;
- // show song name info text
- display_song_name_mc.title_txt.text = play_list[song_number].track+" - "+play_list[song_number].artist;
- // create time loop for display time
- timer = setInterval(display_time, 1000);
- };
- // if play/pause button over, call this function
- play_pause_mc.onRollOver = function() {
- if (playing_status) {
- play_pause_mc.gotoAndStop("pause_over" );
- } else {
- play_pause_mc.gotoAndStop("play_over" );
- }
- };
- // if play/pause button Rollover, call this function
- play_pause_mc.onRollOut = function() {
- if (playing_status) {
- play_pause_mc.gotoAndStop("pause" );
- } else {
- play_pause_mc.gotoAndStop("play" );
- }
- };
- // if play/pause button pressed, call this function
- play_pause_mc.onRelease = function() {
- // controll playing status
- if (playing_status) {
- // if status is playing, goto sound equalizer animation pause section.
- sound_animation_mc.gotoAndPlay("pause" );
- // save current song position
- current_position = mp3_player.position;
- // stop song
- mp3_player.stop();
- // set current song status "stop"
- playing_status = false;
- // goto play/pause button "play"
- play_pause_mc.gotoAndStop("play_over" );
- } else {
- // if current status is pause, goto sound equalizer animation "play" section.
- sound_animation_mc.gotoAndPlay("play" );
- // continue play from paused position
- mp3_player.start(current_position/1000, 1);
- // set status to now playing
- playing_status = true;
- // goto play/pause button to "pause"
- play_pause_mc.gotoAndStop("pause_over" );
- }
- };
- // if "play next song" button over, call this function
- next_mc.onRollOver = function() {
- next_mc.gotoAndStop("next_over" );
- };
- // if "play next song" button rollout, call this function
- next_mc.onRollOut = function() {
- next_mc.gotoAndStop("next" );
- };
- // if "play next song" button pressed, call this function
- next_mc.onRelease = function() {
- sound_animation_mc.gotoAndPlay("play" );
- // call play next song function
- play_next();
- };
- // show current song time and total song time
- display_time = function () {
- // get current song time (millisecond)
- var current_time:Number = mp3_player.position/1000;
- // get total song time (millisecond)
- var total_time:Number = ((mp3_player.duration/((mp3_player.getBytesLoaded()/mp3_player.getBytesTotal())*100))*100)/1000;
- // convert millisecond to second and add zero for display
- if (current_time<total_time) {
- var current_time_minute:Number = add_zero(Math.floor(current_time/60));
- var current_time_second:Number = add_zero(Math.floor(current_time%60));
- var duration_minute:Number = add_zero(Math.floor(total_time/60));
- var duration_second:Number = add_zero(Math.floor(total_time%60));
- // show playing time and total time
- time_txt.text = current_time_minute+":"+current_time_second+" / "+duration_minute+":"+duration_second;
- }
- // if song position arrive to end of song
- if (Math.floor(current_time) == Math.floor(total_time)) {
- if (current_time<>"0" ) {
- // if shuffle mode on
- if (shuffle) {
- // play random song
- shuffle_playlist(current_song_number);
- } else {
- // play ordinary song
- play_next();
- }
- clearInterval(timer);
- }
- }
- };
- // add zero to time function
- add_zero = function (num:Number):String {
- return String(num).length == 1 ? "0"+num : num;
- };
- // Define play next song function
- play_next = function () {
- // check end of playlist
- if (current_song_number<play_list.length-1) {
- // next song number
- current_song_number++;
- } else {
- // set song number to first song
- current_song_number = 0;
- }
- // call play song function
- play_song(current_song_number);
- };
- // Define random song number function
- shuffle_playlist = function (old_song_number) {
- var new_song_number:Number = Math.floor(Math.random()*play_list.length);
- // check old song number diffrent from new song number
- while (new_song_number == old_song_number) {
- new_song_number = Math.floor(Math.random()*play_list.length);
- }
- current_song_number = new_song_number;
- // call play song function
- play_song(new_song_number);
- };
- // calculate loader bar percent function
- loader_status = function () {
- // get loaded info
- var amountLoaded:Number = mp3_player.getBytesLoaded()/mp3_player.getBytesTotal();
- // set loader bar width
- loader.loadbar._width = Math.floor(amountLoaded*100);
- // get total song length.
- trueDuration = Math.ceil((mp3_player.duration/((mp3_player.getBytesLoaded()/mp3_player.getBytesTotal())*100))*100);
- if (drag_start == false) {
- // set position loader bar scrub
- loader.scrub._x = (mp3_player.position/trueDuration)*100;
- }
- };
- // create empty movie clip for loader bar scrub
- this.createEmptyMovieClip("vFrame", this.getNextHighestDepth());
- vFrame.onEnterFrame = loader_status;
- // when press to scrub, start drag
- loader.scrub.onPress = function() {
- drag_start = true;
- this.startDrag(false, 0, this._y, 100, this._y);
- };
- // when release scrub, stop dragging and calculate new song position
- loader.scrub.onRelease = loader.scrub.onReleaseOutside=function () {
- loader.scrub.gotoAndStop(1);
- drag_start = false;
- mp3_player.stop();
- // get totoal time
- trueDuration = Math.ceil((mp3_player.duration/((mp3_player.getBytesLoaded()/mp3_player.getBytesTotal())*100))*100);
- // calculate new song position
- current_position = Math.floor(((loader.scrub._x/100)*trueDuration)/1000);
- // start song from new position
- mp3_player.start(current_position, 1);
- this.stopDrag();
- };
- loader.scrub.onRollOver = function() {
- loader.scrub.gotoAndStop(2);
- };
- loader.scrub.onRollOut = function() {
- loader.scrub.gotoAndStop(1);
- };
- // when over the show playlist button
- show_playlist_mc.onRollOver = function() {
- if (play_list_open == false) {
- show_playlist_mc.gotoAndStop("open_over" );
- } else {
- show_playlist_mc.gotoAndStop("close_over" );
- }
- };
- // when rollout the show playlist button
- show_playlist_mc.onRollOut = function() {
- if (play_list_open == false) {
- show_playlist_mc.gotoAndStop("open" );
- } else {
- show_playlist_mc.gotoAndStop("close" );
- }
- };
- // when pressed the show playlist button
- show_playlist_mc.onRelease = function() {
- if (move_stop == false) {
- if (play_list_open == false) {
- // playlist movie clip move distance (goto down)
- var distance_y = 155;
- show_playlist_mc.gotoAndStop("close_over" );
- } else {
- // playlist movie clip move distance (goto up)
- var distance_y = -155;
- show_playlist_mc.gotoAndStop("open_over" );
- }
- // set reverse boolean value
- play_list_open = !play_list_open;
- // call playlist move function..(0.3 = move speed)
- content_move(play_list_mc, distance_y, 0.3);
- }
- };
- // Define Playlist Box (content) main scroller function. (target MC, scroll distance, scroll speed)
- function content_move(target:MovieClip, scroll_distance_y:Number, speed:Number) {
- move_stop = true;
- current_y = target._y;
- target.onEnterFrame = function() {
- if (scroll_distance_y<0) {
- current_scroll_distance = Math.floor(((scroll_distance_y+current_y)-target._y)*speed);
- } else {
- current_scroll_distance = Math.ceil(((scroll_distance_y+current_y)-target._y)*speed);
- }
- if (target._y == scroll_distance_y+current_y) {
- move_stop = false;
- delete target.onEnterFrame;
- }
- target._y += current_scroll_distance;
- };
- }
- // when pressed the mute button
- mute_mc.onRelease = function() {
- if (mute == false) {
- old_volume = player_volume;
- player_volume = 0;
- set_volume(player_volume);
- mute = true;
- mute_mc.gotoAndStop("mute_on_over" );
- } else {
- player_volume = old_volume;
- set_volume(player_volume);
- mute = false;
- mute_mc.gotoAndStop("mute_off_over" );
- }
- };
- mute_mc.onRollOver = function() {
- if (mute == false) {
- mute_mc.gotoAndStop("mute_off_over" );
- } else {
- mute_mc.gotoAndStop("mute_on_over" );
- }
- };
- mute_mc.onRollOut = function() {
- if (mute == false) {
- mute_mc.gotoAndStop("mute_off" );
- } else {
- mute_mc.gotoAndStop("mute_on" );
- }
- };
- set_volume = function (player_volume) {
- mp3_player.setVolume(player_volume);
- volume_control_mc.volume_bar_mc._width = volume_control_mc.slider_mc._x=(player_volume/100)*100;
- };
- shuffle_mc.onRollOver = function() {
- var goto_shuffle:String = shuffle ? "shuffle_on_over" : "shuffle_off_over";
- shuffle_mc.gotoAndStop(goto_shuffle);
- };
- shuffle_mc.onRollOut = function() {
- var goto_shuffle:String = shuffle ? "shuffle_on" : "shuffle_off";
- shuffle_mc.gotoAndStop(goto_shuffle);
- };
- shuffle_mc.onRelease = function() {
- shuffle = !shuffle;
- var goto_shuffle:String = shuffle ? "shuffle_on" : "shuffle_off";
- shuffle_mc.gotoAndStop(goto_shuffle);
- };
|
|