• 2007-09-27

    歌词同步版 在线播放器mp3

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://wxsr.blogbus.com/logs/10047476.html

    load_lrc.as

    System.useCodepage = true;
    var lrc_url:String = "http://lrc.bzmtv.com/";
    var lrcData:String;
    var now:Number = 1;
    function jiaZai (sPost:String) {
     var lrc_lv:LoadVars = new LoadVars ();
     lrc_lv.load (lrc_url + "so.asp?y=1&key=" + escape (sPost));
     lrc_lv.onData = function (s:String):Void  {  s = unescape (s).toLowerCase ();
      jieXi (s);
      now = 1;
     };
    }
    function jieXi (sData:String):Void {
     lrcData = sData;
     if (lrcData.indexOf ("sorry") != -1) {
      //trace ("没有找到与 [" + so_txt.text + "] 有关的lrc歌词信息!");
      _root.geci_txt.text = "没有找到与 [" + sound_list[SOUND_ID][1] + "] 有关歌词信息!";
      return;
     }
     var sOne:String = qieChu (lrcData, "<a href=\"down.asp?key=", "\"");
     var sTwo:String = lrc_url + qieChu (lrcData, "<a href=\"", "\"");
     _root.geci_txt.text = "请选择下载当前歌曲歌词!";
     trace(sTwo+"=="+sOne)
     list_cb.addItem ({data:sTwo, label:sOne});
     /////////////////////////////////
     if (lrcData.indexOf (".lrc", 0) != -1) {
      now++;
      jieXi (lrcData);
     }
    }
    sound_mode_obj = {};
    sound_mode_obj.change = function (event_obj:Object) {
     geci_txt.text = "";
     load_lrc_func (event_obj.target.selectedItem.data);
     trace (event_obj.target.selectedItem.data + "++++++++++++++");
     list_cb._visible = false;
    };
    list_cb.addEventListener ("change", sound_mode_obj);
    function qieChu (s:String, k:String, j:String):String {
     var nK:Number = s.indexOf (k);
     var sK:String = s.substr (nK + k.length);
     var nJ:Number = sK.indexOf (j);
     lrcData = sK.substr (nJ + j.length);
     return (sK.substr (0, nJ));
    }

     

     

     

    sound_xml.as

     

    //xml解释
    sound_list=[];
    function explain_xml (url:String, arr) {
     var xml_obj = new XML ();
     xml_obj.ignoreWhite = true;
     xml_obj.load (url);
     xml_obj.onLoad = function (success) {
      if (success) {
       var info_xml = [];
       var xml = this;
       var length_ = xml.firstChild.childNodes.length;
       var arr_last_val = arr[arr.length - 1];
       for (var j = 0; j < length_; j++) {
        for (var i = 0; i < xml.firstChild.childNodes[j].childNodes.length; i++) {
         var ad = xml.firstChild.childNodes[j].firstChild.nodeValue;
         var name_ = xml.firstChild.childNodes[j].attributes.name_id;
         var num = xml.firstChild.childNodes[j].attributes.id;
         info_xml.push ([ad, name_, num]);
         sound_list = info_xml;
         gotoAndStop(2)
        }
       }
      }
     };
    }
    if (XML_AD == undefined) {
     gotoAndStop(2)
     explain_xml ("http://elite2portal:4444/main/soundList.xml", arr);
    }
    else {
     explain_xml (XML_AD, arr);
    }
    stop()

     

     

     

    main.as

     

    stop ();
    System.security.allowInsecureDomain ("*");
    System.security.allowDomain ("*");
    System.useCodepage = true;
    var sound_list_arr;
    //var sound_list = [];
    var frame_bar_x;
    var now_bar_x;
    var total_time;
    var load_position;
    var play_position;
    var change_position;
    var position_x = getBound (bar.total_x);
    var list_mc_higth;
    var push = false;
    var mouse_down = false;
    var count = 0;
    var my_sound:Sound = new Sound ();
    var SOUND_ID = 0;
    var Sound_push = false;
    var count_num = 0;
    set_Volume = false;
    bar.load_bar._xscale = 0;
    bar.play_bar._xscale = 0;
    Volume_btn.cnt = 0;
    this.createEmptyMovieClip ("sound_list_obj", this.getNextHighestDepth ());
    this.attachMovie ("mask", "mask", this.getNextHighestDepth ());
    mask._x = list_mc._x + list_mc.point_bar._x - 200;
    mask._y = list_mc._y + list_mc.point_bar._y;
    sound_list_obj._x = list_mc._x + list_mc.point_bar._x - 200;
    sound_list_obj._y = list_mc._y + list_mc.point_bar._y;
    //歌曲菜单列表歌曲选择
    sound_list_obj.onEnterFrame = function () {
     if (sound_list[0] != undefined) {
      delete this.onEnterFrame;
      btn_event ();
      sound_list_info (sound_list);
      check_func (sound_list[SOUND_ID][2]);
      my_sound.loadSound (sound_list[SOUND_ID][0], true);
      mask.setMask (sound_list_obj);
      sound_list_obj.sound_list_mc.setMask (mask);
      //getID3()
      lrc_func ();
     }
    };
    //歌曲菜单列初始化
    function sound_list_info (arr) {
     sound_list_arr = [];
     sound_list_obj.createEmptyMovieClip ("sound_list_mc", this.getNextHighestDepth ());
     for (var i = 0; i < arr.length; i++) {
      var txt_mc = "txt_mc" + i;
      var mc = sound_list_obj.sound_list_mc.attachMovie ("txt_mc", txt_mc, this.getNextHighestDepth () + i);
      mc.txt.text = i + "." + arr[i][1];
      mc._y = 20 * i;
      mc.bg._visible = false;
      sound_list_arr.push ({mc:mc, ad:arr[i][0], name_:arr[i][1], num:arr[i][2]});
     }
    }
    //检查于列表中选择歌曲
    function check_change (arr) {
     if (push == false) {
      for (var i = 0; i < arr.length; i++) {
       if (mask.hitTest (_xmouse, _ymouse, false)) {
        if (arr[i].mc.hitTest (_xmouse, _ymouse, true) && mask.hitTest (_xmouse, _ymouse, false)) {
         arr[i].mc.bg._visible = true;
        }
        else {
         arr[i].mc.bg._visible = false;
        }
        arr[i].mc.id = i;
        arr[i].mc.onPress = function () {
         if (mouse_down) {
          list_move = false;
          list.num = 0;
          stor2 (sound_list, arr[this.id].num);
         }
        };
       }
       else {
        arr[i].mc.bg._visible = false;
       }
      }
     }
    }
    //歌曲播放完后事件
    function after_sound () {
     if (my_sound.position / 1000 >= int (total_time / 100) / 10 && my_sound.position > 2000) {
      sound_time = 0;
      SOUND_ID++;
      atot_ ();
      trace ("mySoundID completed");
      delete my_sound;
      check_func (sound_list[SOUND_ID][2]);
      my_sound = new Sound ();
      my_sound.loadSound (sound_list[SOUND_ID][0], true);
      bar.position_bar._x = 0;
      lrc_func ();
     }
    }
    //换歌后更新歌曲菜单列表
    function stor2 (arr1, num) {
     var tmp_arr = [];
     for (var i = 0; i < arr1.length; i++) {
      if (arr1[i][2] == num) {
       SOUND_ID = i;
       check_func (sound_list[SOUND_ID][2]);
       my_sound = new Sound ();
       my_sound.loadSound (sound_list[SOUND_ID][0], true);
       lrc_func ();
       break;
      }
     }
    }
    this.onEnterFrame = function () {
     if (list_move) {
      if (list_mc._x > 140) {
       list_mc._x -= 20;
       mask._x -= 20;
       sound_list_obj._x -= 20;
      }
     }
     else {
      if (list_mc._x < 450) {
       list_mc._x += 20;
       mask._x += 20;
       sound_list_obj._x += 20;
      }
     }
     after_sound ();
     total_position (bar, my_sound);
     if (sound_list_arr[0] != undefined) {
      check_change (sound_list_arr);
     }
    };
    // 检查边界;
    function getBound (mc) {
     position_x = mc.getBounds ().xMax;
     return position_x;
    }
    ///
    order_num = 0;
    _root.tmp_positon = 0;
    _root.tmp_time_num = 0;
    //信息显示
    function total_position (mc, my_sound) {
     if (sound_list[SOUND_ID][1] != old_list) {
      var str = "          " + sound_list[SOUND_ID][1];
      _root.SOUND_NAME_ = str.split ("");
     }
     old_list = sound_list[SOUND_ID][1];
     count_num++;
     var txt = "";
     if (count_num >= 2) {
      count_num = 0;
      var tmp = _root.SOUND_NAME_[0];
      _root.SOUND_NAME_.shift ();
      _root.SOUND_NAME_.push (tmp);
      for (var s = 0; s < 10; s++) {
       txt += _root.SOUND_NAME_[s];
      }
      if (old_list == undefined) {
       if (XML_AD == undefined) {
        txt = " mp3播放器";
       }
       else {
        txt = "  服务器繁忙!";
       }
      }
      TXT_FILE.text = "File:" + txt;
     }
     ///////////////////test            
     if (my_sound.position <= 2) {
     }
     //trace(my_sound.position+"=="+time_order[order_num].time_num)         
     if (my_sound.position < _root.tmp_positon) {
      for (var c = 0; c < time_order.length; c++) {
       if (time_order[c].time_num >= my_sound.position) {
        if (time_order[c - 1].txt != undefined) {
         geci_txt.text = "";
         geci_txt.text += time_order[c - 1].txt + newline;
         //geci_txt.text += time_order[c].txt;
        }
        _root.tmp_positon = my_sound.position;
        _root.tmp_time_num = time_order[c].time_num;
        break;
       }
      }
     }
     if (my_sound.position > _root.tmp_time_num) {
      for (var c = 0; c < time_order.length; c++) {
       if (time_order[c].time_num >= my_sound.position) {
        if (time_order[c - 1].txt != undefined) {
         geci_txt.text = "";
         geci_txt.text += time_order[c - 1].txt + newline;
         //geci_txt.text += time_order[c].txt;
        }
        _root.tmp_positon = my_sound.position;
        _root.tmp_time_num = time_order[c].time_num;
        break;
       }
      }
     }
     /*
     if (my_sound.position>=time_order[order_num].time_num) {
     if (time_order[order_num].txt != undefined) {
     geci_txt.text = time_order[order_num].txt;
     }
     //trace (time_order[order_num].txt);  
     order_num++;
     }*/
     ///////////////////////test   
     var msec = (my_sound.position % 1000);
     var sece = (my_sound.position / 1000 % 60);
     var min = (my_sound.position / 1000 / 60);
     //sound_txt.text = "  Time: " + int (total_time / 100) / 10 + " / " + int (my_sound.position / 1000 * 10) / 10;
     sound_txt.text = "  Time:  " + int (min) + ":" + int (sece) + ":" + int (msec);
     if (my_sound.getBytesLoaded () < my_sound.getBytesTotal ()) {
      if (!push) {
       if (val_position == my_sound.position) {
        count++;
        //trace(count);
        if (count > 150) {
         /*
         count = 0
         sound_time = 0;
         SOUND_ID++;
         atot_();
         delete my_sound;
         my_sound = new Sound();
         check_func(sound_list[SOUND_ID][2]);
         my_sound.loadSound(sound_list[SOUND_ID][0], true);
         bar.position_bar._x = 0;
         */
        }
        if (count > 7) {
         info_txt.text = "缓冲中.....";
         if (info_txt._x > 175) {
          info_txt._x -= 15;
         }
        }
       }
       else {
        count = 0;
        info_txt.text = "";
        if (info_txt._x < 250) {
         info_txt._x += 15;
        }
       }
      }
     }
     //歌曲总时间                        
     total_time = my_sound.duration / my_sound.getBytesLoaded () * my_sound.getBytesTotal ();
     //进度控制
     now_bar_x = play_position * position_x / 100;
     frame_bar_x = now_bar_x - tmp_bar_x;
     bar.position_bar._x = now_bar_x;
     //播放进度
     play_position = int (my_sound.position / total_time * 100);
     //下载进度
     load_position = int (my_sound.getBytesLoaded () / my_sound.getBytesTotal () * 100);
     bar.load_bar._xscale = load_position;
     bar.play_bar._xscale = play_position;
     tmp_bar_x = now_bar_x;
     val_position = my_sound.position;
    }
    onMouseDown = function () {
     mouse_down = true;
    };
    onMouseUp = function () {
     mouse_down = false;
    };
    //按钮事件
    function btn_event () {
     stop_btn.cnt = 0;
     stop_btn.onPress = function () {
      this.cnt++;
      if (this.cnt % 2 == 1) {
       stop_btn.gotoAndStop (2);
       sound_time = my_sound.position / 1000;
       my_sound.stop ();
       push = true;
       Sound_push = true;
      }
      else {
       stop_btn.gotoAndStop (1);
       my_sound.start (sound_time);
       push = false;
       Sound_push = false;
      }
     };
     stop_btn.onRollOut = function () {
      this.bnt.gotoAndStop (1);
     };
     stop_btn.onRollOver = function () {
      this.bnt.gotoAndStop (2);
     };
     again_btn.onPress = function () {
      sound_time = 0;
      my_sound.start (0);
      my_sound.stop ();
      //stop_btn.gotoAndStop (1);
      Sound_push = true;
      stop_btn.cnt = 1;
      lrc_func ();
     };
     next_btn.onPress = function () {
      stop_btn.gotoAndStop (1);
      sound_time = 0;
      stop_btn.cnt = 0;
      SOUND_ID++;
      atot_ ();
      delete my_sound;
      my_sound = new Sound ();
      check_func (sound_list[SOUND_ID][2]);
      my_sound.loadSound (sound_list[SOUND_ID][0], true);
      bar.position_bar._x = 0;
      lrc_func ();
      //getID3()
     };
     up_btn.onPress = function () {
      stop_btn.gotoAndStop (1);
      sound_time = 0;
      stop_btn.cnt = 0;
      SOUND_ID--;
      atot_ ();
      delete my_sound;
      my_sound = new Sound ();
      check_func (sound_list[SOUND_ID][2]);
      my_sound.loadSound (sound_list[SOUND_ID][0], true);
      bar.position_bar._x = 0;
      lrc_func ();
     };
     Volume_btn.onPress = function () {
      this.cnt++;
      if (this.cnt % 2 == 1) {
       _root.my_sound.setVolume (0);
       this.gotoAndStop (2);
      }
      else {
       this.gotoAndStop (1);
       trace (_root._volume);
       _root.my_sound.setVolume (_root._volume);
      }
     };
     Volume_btn.onRollOut = function () {
      this.bnt.gotoAndStop (1);
     };
     Volume_btn.onRollOver = function () {
      this.bnt.gotoAndStop (2);
     };
     list.num = 0;
     list.onPress = function () {
      this.num++;
      if (this.num % 2 == 1) {
       list_move = true;
      }
      else {
       list_move = false;
      }
     };
    }
    //歌曲列表菜单选中后字体颜色设置
    function check_func (num) {
     for (var i = 0; i < sound_list_arr.length; i++) {
      if (sound_list_arr[i].num == num) {
       sound_list_arr[i].mc.txt.textColor = 0xFF0000;
      }
      else {
       sound_list_arr[i].mc.txt.textColor = 0x000000;
      }
     }
    }
    //歌曲列表播放完毕后重新归0
    function atot_ () {
     if (SOUND_ID > sound_list.length - 1) {
      SOUND_ID = 0;
     }
     else if (SOUND_ID < 0) {
      SOUND_ID = sound_list.length - 1;
     }
    }
    digui_num = 0;
    function lrc_func () {
     list_cb.removeAll ();
     list_cb.addItem ({label:"请选择下载当前歌曲lrc歌词文件"});
     
     list_cb._visible = true;
     sound_info = [];
     time_order = [];
     _root.tmp_positon = 0;
     _root.tmp_time_num = 0;
     order_num = 0;
     geci_txt.text = "";
     //jiaZai (sound_list[SOUND_ID][1]);
     load_lrc_func (sound_list[SOUND_ID][1])
    }
    function getID3 () {
     my_sound.onID3 = function () {
      for (var prop in my_sound.id3) {
       trace (prop + " : " + my_sound.id3[prop]);
      }
     };
    }

     show_lrc.as

    System.useCodepage = true;
    var sound_info = [];
    var time_order = [];
    function load_lrc_func (url) {
     if(_root.LRC_URL==undefined){
     url="http://elite2portal:4444/main/touatoua.asp?lrczhi="+url;
     }else{
      url=_root.LRC_URL+url
      
      }
     sound_info = [];
     time_order = [];
     var lrc_lv:LoadVars = new LoadVars ();
     lrc_lv.load (url);
     trace ("url=" + url);
     lrc_lv.onData = function (s:String):Void  {
      trace(s)
      var new_arr = s.split ("\r").join ("").split ("\n");
      sound_info = exp_str (new_arr);
      var tmp = sort2 (stor_info (sound_info));
     };
     //
    }
    function trace_func (arr) {
     for (var i = 0; i < arr.length; i++) {
      trace (arr[i].time_num);
     }
    }
    function sort2 (arr, flag) {
     for (var i = 0; i < arr.length - 1; i++) {
      for (var j = i + 1; j < arr.length; j++) {
       if (arr[i].time_num > arr[j].time_num) {
        var tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
       }
      }
     }
     if (flag) {
      arr.reverse ();
     }
     return arr;
    }
    function stor_info (arr) {
     _root.info_arr = [];
     for (var i = 0; i < arr.length; i++) {
      if (arr[i][0][0].ti == undefined) {
       for (var j = 0; j < arr[i][0].length; j++) {
        time_order.push ({time_num:arr[i][0][j], txt:arr[i][1]});
       }
      }
      else {
       info_arr.push (arr[i][0][0]);
      }
     }
     return time_order;
    }
    function exp_str (arr:Array) {
     for (var i = 0; i < arr.length; i++) {
      var num = arr[i].lastIndexOf ("]") + 1;
      var word_1 = arr[i].substr (0, num);
      var word_2 = arr[i].substr (num, tarr[i].length);
      var new_arr = word_1.split ("[").join ("").split ("/r").join ("").split ("]");
      new_arr.pop ();
      for (var j = 0; j < new_arr.length; j++) {
       var tmp_arr = new_arr[j].split (":");
       var tmp_arr_child = tmp_arr[1].split (".");
       var msce = Number (tmp_arr[0]) * 60000 + Number (tmp_arr_child[0]) * 1000 + Number (tmp_arr_child[1]);
       if (int (msce) == 0) {
        new_arr[j] = {ti:tmp_arr[0], txt:tmp_arr[1]};
       }
       else {
        new_arr[j] = int (msce);
       }
      }
      if (i < arr.length - 1) {
       if (word_2 != "") {
        arr[i] = [new_arr, word_2];
       }
       else {
        arr[i] = [new_arr];
       }
      }
     }
     return arr;
    }

     

    限于flash的安全问题 下边是Ajarx 写的一个盗连程序

    只要别的网站有这个 ws方法提供那么这个flash的这个安全限制就等于没有了

    <%
    lrczhi=request("lrczhi")
    %>
    <%
    function getHTTPPage(url)
        dim Http
        set Http=server.createobject("Microsoft.XMLHTTP")
        Http.open "GET",url,false
        Http.send()
        if Http.readystate<>4 then
            exit function
        end if
        getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
        set http=nothing
        if err.number<>0 then err.Clear
    end function

    Function BytesToBstr(body,Cset)
            dim objstream
            set objstream = Server.CreateObject("adodb.stream")
            objstream.Type = 1
            objstream.Mode =3
            objstream.Open
            objstream.Write body
            objstream.Position = 0
            objstream.Type = 2
            objstream.Charset = Cset
            BytesToBstr = objstream.ReadText
            objstream.Close
            set objstream = nothing
    End Function

    Dim Url,Html
    Url="http://club.you800.cn/showlrc.asp?sname="+lrczhi
    Html = getHTTPPage(Url)
    Response.write Html
    %>

     

     

     


    收藏到:Del.icio.us




发表评论

您将收到博主的回复邮件
记住我