amocthong
Private
- Tham gia
- 10/09/2015
- Bài viết
- 36
- Được Like
- 16
em có 1 code jquery chạy nhạc bằng file xml nhưng em chỉ có code k có file xml anh nào rành xin giúp em với ạ
HTML:
<script>
function content_move(target, scroll_distance_y, speed)
{
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 = target._y + current_scroll_distance;
};
}
var mp3_player = new Sound(this);
var player_volume = 75;
var shuffle = false;
var play_list = [];
var current_position = 0;
var current_song_number = 0;
var play_list_open = true;
var playing_status = false;
var drag_start = false;
var move_stop = false;
play_list_mc.setMask(mask_mc);
play_list_mc._y = play_list_mc._y - play_list_mc._height;
var mute = false;
var goto_shuffle = !shuffle?"shuffle_off":"shuffle_on";
shuffle_mc.gotoAndStop(goto_shuffle);
var play_list_xml = new XML();
play_list_xml.ignoreWhite = true;
play_list_xml.onLoad = function(load_status)
{
var _loc3_ = this.firstChild.childNodes;
play_list_length = _loc3_.length;
var _loc2_ = 0;
while(_loc2_ < _loc3_.length)
{
play_list.push({url:_loc3_[_loc2_].attributes.url,artist:_loc3_[_loc2_].attributes.artist,track:_loc3_[_loc2_].attributes.track});
_loc2_ = _loc2_ + 1;
}
create_play_list();
if(shuffle)
{
shuffle_playlist(current_song_number);
}
else
{
play_song;
display_song_name_mc.title_txt.text = "";
sound_animation_mc.gotoAndPlay("pause");
}
};
play_list_xml.load("/WSFile/Nhac/Nhac.xml");
create_play_list = function()
{
var _loc2_ = this.play_list_mc.scroller_mc.mc.song_name_mc.text_mc;
_loc2_.name_txt.text = play_list[0].track + " - " + play_list[0].artist;
_loc2_.number_txt.text = "01.";
this.play_list_mc.scroller_mc.mc.song_name_mc.color_bar_mc.id = 0;
i = 2;
while(i < play_list_length + 1)
{
_loc2_ = this.play_list_mc.scroller_mc.mc.song_name_mc.duplicateMovieClip("song_name" + i,i);
_loc2_.color_bar_mc.id = i - 1;
_loc2_._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);
_loc2_.text_mc.name_txt.text = play_list[i - 1].track + " - " + play_list[i - 1].artist;
if(i < 10)
{
_loc2_.text_mc.number_txt.text = "0" + String(i) + ".";
}
else
{
_loc2_.text_mc.number_txt.text = String(i) + ".";
}
i++;
}
if(play_list_open)
{
var _loc3_ = 111;
show_playlist_mc.gotoAndStop("close");
content_move(play_list_mc,_loc3_,0.3);
}
};
play_song = function(song_number)
{
mp3_player.stop();
mp3_player.start(0,1);
mp3_player.loadSound(play_list[song_number].url,true);
set_volume(player_volume);
play_pause_mc.gotoAndStop("pause");
playing_status = true;
display_song_name_mc.title_txt.text = play_list[song_number].track + " - " + play_list[song_number].artist;
sound_animation_mc.gotoAndPlay("play");
timer = setInterval(display_time,1000);
};
play_pause_mc.onRollOver = function()
{
if(playing_status)
{
play_pause_mc.gotoAndStop("pause_over");
}
else
{
play_pause_mc.gotoAndStop("play_over");
}
};
play_pause_mc.onRollOut = function()
{
if(playing_status)
{
play_pause_mc.gotoAndStop("pause");
}
else
{
play_pause_mc.gotoAndStop("play");
}
};
play_pause_mc.onRelease = function()
{
if(playing_status)
{
sound_animation_mc.gotoAndPlay("play");
current_position = mp3_player.position;
sound_animation_mc.gotoAndPlay("pause");
mp3_player.stop();
playing_status = false;
play_pause_mc.gotoAndStop("play_over");
}
else
{
sound_animation_mc.gotoAndPlay("play");
mp3_player.start(current_position / 1000,1);
playing_status = true;
play_pause_mc.gotoAndStop("pause_over");
}
};
next_mc.onRollOver = function()
{
next_mc.gotoAndStop("next_over");
};
next_mc.onRollOut = function()
{
next_mc.gotoAndStop("next");
};
next_mc.onRelease = function()
{
sound_animation_mc.gotoAndPlay("play");
play_next();
};
display_time = function()
{
var _loc1_ = mp3_player.position / 1000;
var _loc2_ = mp3_player.duration / mp3_player.getBytesLoaded() / mp3_player.getBytesTotal() * 100 * 100 / 1000;
if(_loc1_ < _loc2_)
{
var _loc3_ = add_zero(Math.floor(_loc1_ / 60));
var _loc6_ = add_zero(Math.floor(_loc1_ % 60));
var _loc4_ = add_zero(Math.floor(_loc2_ / 60));
var _loc5_ = add_zero(Math.floor(_loc2_ % 60));
time_txt.text = _loc3_ + ":" + _loc6_ + " / " + _loc4_ + ":" + _loc5_;
}
if(Math.floor(_loc1_) == Math.floor(_loc2_))
{
if(!(_loc1_ == "0"))
{
if(shuffle)
{
shuffle_playlist(current_song_number);
}
else
{
play_next();
}
clearInterval(timer);
}
}
};
add_zero = function(num)
{
return String(num).length != 1?num:"0" + num;
};
play_next = function()
{
if(current_song_number < play_list.length - 1)
{
current_song_number++;
}
else
{
current_song_number = 0;
}
play_song(current_song_number);
};
shuffle_playlist = function(old_song_number)
{
var _loc1_ = Math.floor(Math.random() * play_list.length);
while(_loc1_ == old_song_number)
{
_loc1_ = Math.floor(Math.random() * play_list.length);
}
current_song_number = _loc1_;
play_song(_loc1_);
};
loader_status = function()
{
var _loc1_ = mp3_player.getBytesLoaded() / mp3_player.getBytesTotal();
loader.loadbar._width = Math.floor(_loc1_ * 100);
trueDuration = Math.ceil(mp3_player.duration / mp3_player.getBytesLoaded() / mp3_player.getBytesTotal() * 100 * 100);
if(drag_start == false)
{
loader.scrub._x = mp3_player.position / trueDuration * 100;
}
};
this.createEmptyMovieClip("vFrame",this.getNextHighestDepth());
vFrame.onEnterFrame = loader_status;
loader.scrub.onPress = function()
{
drag_start = true;
this.startDrag(false,0,this._y,100,this._y);
};
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function()
{
loader.scrub.gotoAndStop(1);
drag_start = false;
mp3_player.stop();
trueDuration = Math.ceil(mp3_player.duration / mp3_player.getBytesLoaded() / mp3_player.getBytesTotal() * 100 * 100);
current_position = Math.floor(loader.scrub._x / 100 * trueDuration / 1000);
mp3_player.start(current_position,1);
this.stopDrag();
};
loader.scrub.onRollOver = function()
{
loader.scrub.gotoAndStop(2);
};
loader.scrub.onRollOut = function()
{
loader.scrub.gotoAndStop(1);
};
show_playlist_mc.onRollOver = function()
{
if(play_list_open == false)
{
show_playlist_mc.gotoAndStop("open_over");
}
else
{
show_playlist_mc.gotoAndStop("close_over");
}
};
show_playlist_mc.onRollOut = function()
{
if(play_list_open == false)
{
show_playlist_mc.gotoAndStop("open");
}
else
{
show_playlist_mc.gotoAndStop("close");
}
};
show_playlist_mc.onRelease = function()
{
if(move_stop == false)
{
if(play_list_open == false)
{
var _loc1_ = 155;
show_playlist_mc.gotoAndStop("close_over");
}
else
{
_loc1_ = -155;
show_playlist_mc.gotoAndStop("open_over");
}
play_list_open = !play_list_open;
content_move(play_list_mc,_loc1_,0.3);
}
};
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 _loc1_ = !shuffle?"shuffle_off_over":"shuffle_on_over";
shuffle_mc.gotoAndStop(_loc1_);
};
shuffle_mc.onRollOut = function()
{
var _loc1_ = !shuffle?"shuffle_off":"shuffle_on";
shuffle_mc.gotoAndStop(_loc1_);
};
shuffle_mc.onRelease = function()
{
shuffle = !shuffle;
var _loc1_ = !shuffle?"shuffle_off":"shuffle_on";
shuffle_mc.gotoAndStop(_loc1_);
};
</script>
Bài viết liên quan
Bài viết mới