Help Giúp Tạo XML playlist Nhạc

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>
 
  • Like
Reactions: THB

vanphu113

Moderator
Thành viên BQT
Tham gia
10/11/2016
Bài viết
161
Được Like
103
ban lay code nay o dau ?
ban tham khao nhe:
Mã:
<music>
  <artist name="Radiohead">
    <album title="The King of Limbs">
      <song title="Bloom" length="5:15"/>
      <song title="Morning Mr Magpie" length="4:41"/>
      <song title="Little by Little" length="4:27"/>
      <song title="Feral" length="3:13"/>
      <song title="Lotus Flower" length="5:01"/>
      <song title="Codex" length="4:47"/>
      <song title="Give Up the Ghost" length="4:50"/>
      <song title="Separator" length="5:20"/>
      <description link="http://en.wikipedia.org/wiki/The_King_of_Limbs">
    The King of Limbs is the eighth studio album by English rock band Radiohead, produced by Nigel Godrich. It was self-released on 18 February 2011 as a download in MP3 and WAV formats, followed by physical CD and 12" vinyl releases on 28 March, a wider digital release via AWAL, and a special "newspaper" edition on 9 May 2011. The physical editions were released through the band's Ticker Tape imprint on XL in the United Kingdom, TBD in the United States, and Hostess Entertainment in Japan.
      </description>
    </album>
    <album title="OK Computer">
      <song title="Airbag"  length="4:44"/>
      <song title="Paranoid Android"  length="6:23"/>
      <song title="Subterranean Homesick Alien"  length="4:27"/>
      <song title="Exit Music (For a Film)"  length="4:24"/>
      <song title="Let Down"  length="4:59"/>
      <song title="Karma Police"  length="4:21"/>
      <song title="Fitter Happier"  length="1:57"/>
      <song title="Electioneering"  length="3:50"/>
      <song title="Climbing Up the Walls"  length="4:45"/>
      <song title="No Surprises"  length="3:48"/>
      <song title="Lucky"  length="4:19"/>
      <song title="The Tourist"  length="5:24"/>
      <description link="http://en.wikipedia.org/wiki/OK_Computer">
    OK Computer is the third studio album by the English alternative rock band Radiohead, released on 16 June 1997 on Parlophone in the United Kingdom and 1 July 1997 by Capitol Records in the United States. It marks a deliberate attempt by the band to move away from the introspective guitar-oriented sound of their previous album The Bends. Its layered sound and wide range of influences set it apart from many of the Britpop and alternative rock bands popular at the time and laid the groundwork for Radiohead's later, more experimental work.
      </description>
    </album>
  </artist>
  <artist name="Portishead">
    <album title="Dummy">
      <song title="Mysterons"  length="5:02"/>
      <song title="Sour Times"  length="4:11"/>
      <song title="Strangers"  length="3:55"/>
      <song title="It Could Be Sweet"  length="4:16"/>
      <song title="Wandering Star"  length="4:51"/>
      <song title="It's a Fire"  length="3:49"/>
      <song title="Numb"  length="3:54"/>
      <song title="Roads"  length="5:02"/>
      <song title="Pedestal"  length="3:39"/>
      <song title="Biscuit"  length="5:01"/>
      <song title="Glory Box"  length="5:06"/>
      <description link="http://en.wikipedia.org/wiki/Dummy_%28album%29">
    Dummy is the debut album of the Bristol-based group Portishead. Released in August 22, 1994 on Go! Discs, the album earned critical acclaim, winning the 1995 Mercury Music Prize. It is often credited with popularizing the trip-hop genre and is frequently cited in lists of the best albums of the 1990s. Although it achieved modest chart success overseas, it peaked at #2 on the UK Album Chart and saw two of its three singles reach #13. The album was certified gold in 1997 and has sold two million copies in Europe. As of September 2011, the album was certified double-platinum in the United Kingdom and has sold as of September 2011 825,000 copies.
      </description>
    </album>
    <album title="Third">
      <song title="Silence"  length="4:58"/>
      <song title="Hunter"  length="3:57"/>
      <song title="Nylon Smile"  length="3:16"/>
      <song title="The Rip"  length="4:29"/>
      <song title="Plastic"  length="3:27"/>
      <song title="We Carry On"  length="6:27"/>
      <song title="Deep Water"  length="1:31"/>
      <song title="Machine Gun"  length="4:43"/>
      <song title="Small"  length="6:45"/>
      <song title="Magic Doors"  length="3:32"/>
      <song title="Threads"  length="5:45"/>
      <description link="http://en.wikipedia.org/wiki/Third_%28Portishead_album%29">
    Third is the third studio album by English musical group Portishead, released on 27 April 2008, on Island Records in the United Kingdom, two days after on Mercury Records in the United States, and on 30 April 2008 on Universal Music Japan in Japan. It is their first release in 10 years, and their first studio album in eleven years. Third entered the UK Album Chart at #2, and became the band's first-ever American Top 10 album on the Billboard 200, reaching #7 in its entry week.
      </description>
    </album>
  </artist>
</music>
 

amocthong

Private
Tham gia
10/09/2015
Bài viết
36
Được Like
16
mình lấy code này từ filr swf của 1 trang web mà bị mất file xml nên h muốn làm lại thanks bạn để mình test
 

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mobile/Zalo: 0906081284

Telegram: anhanhxf

Chỉ nhận web nội dung lành mạnh

Nhà Tài Trợ

Mút Xốp Không Gian
Mút Sofa Không Gian
Top Bottom