define("js/view/playerBar.js",function(t,e,o){ var i = t("js/lib/zepto.js"), a = t("js/lib/music.js"), n = t("js/lib/backbone.js"), s = t("js/ui/timeFormat.js"), d = n.View.extend({ el:"#player_bar", initialize:function(){ var t = this; this.listenTo(this.model,"change:playId",this.changeId), this.listenToOnce(this.model,"change:playId",this.showBtn), this.listenTo(this.model,"change:index",this.changeIndex), this.initAudio(), i("#player_bar").tap(function(e){ e.stopPropagation(), e.preventDefault(); var o=t.model.getSong(); return o ? ( e.target.className.indexOf("btn_download")>=0 ? (t.download(),a.tj.sendClick("song.downloadicon")) : "btn_status"==e.target.id ? (t.togglePlay(),a.tj.sendClick("song.playicon")) : a.router.navigate("player",{trigger:!0}),void 0 ) : !1 }), i("#player_bar .poster").on("error",function(){ this.src="http://imgcache.gtimg.cn/music/mobile/css/img/music_0949f22.png" }) }, initAudio:function(){ var t=this; i(this.model.get("audio")) .on("play",function(){ SPD.pointMark("songload"), i("#btn_status").attr("class","btn_pause"), i(".cover_pic").removeClass("pause"), t.model.set("status",1), i("video")[0]&&i("video")[0].pause() }) .on("pause",function(){ i("#btn_status").attr("class","btn_play"), i(".cover_pic").addClass("pause"), t.model.set("status",0) }) .on("timeupdate",function(){ var e=t.model.get("audio").currentTime, o=t.model.get("audio").duration; i(".has_play").css({width:100*(e/o)+"%"}), i("#current_time").text(s(e)); try{ var a=t.model.get("audio").buffered.end(0); i(".has_load").css({width:100*(a/o)+"%"}) } catch(n){} }) .on("ended",function(){ var e=t.model.get("index"); e++, e>=t.model.get("playList").length&&(e=0), t.model.set("playId",t.model.get("playList").at(e).cid) }) .on("canplay",function(){ t.play() }) .on("error",function(t){ a.tip("歌曲加载失败 T T 请稍候重试!"), a.tj.sendClick("song.playerror"), console.log(t) }) .on("durationchange",function(){ i("#total_time").text(s(t.model.get("audio").duration)) }) }, togglePlay:function(){ this.model.get("audio").paused?this.play():this.pause() }, showBtn:function(){ i("#btn_status,#player_bar .btn_download").show() }, changeId:function(){ var t=this.model.getSong(); this.model.set("index",this.model.get("playList").indexOf(t)), i(".has_play,.has_load").css({width:"0%"}); var e="http://"+a.audioServer+".stream.qqmusic.qq.com/"+(t.get("songid")||"C100"+t.get("songmid"))+".m4a?fromtag=30"; this.model.get("audio").src=e, 0!=this.model.get("audio").readyState&&this.model.get("audio").load(); var o=t.get("albumid"), n="http://imgcache.qq.com/music/photo/album/"+o%100+"/90_albumpic_"+o+"_0.jpg"; i("#player_bar .poster").attr("src",n), i("#player_bar .song").html(t.get("songname")), i("#player_bar .singer").html(t.get("singername")), a.tj.sendClick("song.playtimes") }, play:function(){ this.model.get("audio").play() }, pause:function(){ this.model.get("audio").pause() }, stop:function(){ this.pause() }, speed:function(){ this.model.get("audio").currentTime+=10 }, openSingle:function(){ new playerBox({model:this.model}) }, changeIndex:function(){ this.model.set("playId",this.model.get("playList").at(this.model.get("index")).cid) }, download:function(){ var e=this, o=t("js/ui/dialog.js"); o.opendDialog( "提示", "网页版暂不支持下载,你可以在手机客户端免费下载此歌曲", "在手机QQ音乐中下载", function(){ var i=t("js/ui/openAppSong.js"); i(e.model.getSong()), o.hide() } ) } }); o.exports=d });/* |xGv00|c0a42f805c79489f9535548049f674e3 */
时间: 2024-10-14 23:20:57