new file: pixi.toml
[GalaxyCodeBases.git] / js / ThunderLixianExporter / vod_html5.js
blob270136608e0817301d73cf3885fad584fe2bfd88
1 $("#list_nav_parent").after('<a id="TLE_html5_player" class="page_list" href="#" title="HTML5播放">'
2                               +'<span>HTML5播放器</span>'
3                               +'<span class="p_r"></span>'
4                             +'</a>');
5 $("#TLE_html5_player").click(function() {
6   document.cookie = "html5_player=1";
7   html5player();
8 });
10 function html5player() {
11   function play(url) {
12     url = url.replace(/&n=\w+/, "&n=08586C0FD0F6390000").replace(/&p=\d+/, "")+"&p=1&xplaybackid=0";
13     $("#xl_vod_fx_flash_box").attr("src", url);
14     $("#original_url").html('mplayer播放:'+'<input value="'+play_with_mplayer(url)+'" />');
15     $("#original_url input").attr("style", "background:#777;border:0;width:400px;");
16   }
18   $.getJSON('http://i.vod.xunlei.com/req_get_method_vod?jsonp=?', {
19     url: XL_CLOUD_FX_INSTANCE.curUrl,
20     video_name: XL_CLOUD_FX_INSTANCE.curName,
21     platform: 1,
22     vip: 1,
23     userid: XL_CLOUD_FX_INSTANCE.user.u,
24     sessionid: XL_CLOUD_FX_INSTANCE.user.s,
25     from: 'vlist',
26   }, function(data) {
27       var list = data.resp.vodinfo_list
28       $("#XL_CLOUD_VOD_PLAYER").empty();
29       if (list.length == 0) {
30         $("#XL_CLOUD_VOD_PLAYER").append('<img src="http://vod.xunlei.com/img/play_bg.jpg" width="100%" height="100%"><div style="position:absolute;left:0;top:46%;text-align:center;font-size:14px;color:#FFF;margin: 0;width:100%;height:22px;">云点播尚未转码完成。</div>');
31         return ;
32       };
33       $("#mycopyer").hide();
34       $("#XL_CLOUD_VOD_PLAYER").append('<video id="xl_vod_fx_flash_box" width="100%" height="94%" style="z-index: 100;" controls="controls" autoplay="true"></video>'
35                   +'<div id="xl_button_box" style="width: 100%; height: 6%; line-height: 22px; text-align: right; ">'
36                   +'</div>');
37       list.forEach(function(n, i) {
38         console.log(n);
39         var str = "";
40         switch(n.spec_id) {
41           case 225536:
42           case 226048:
43             str = "360P";
44             break;
45           case 282880:
46           case 283392:
47             str = "480P";
48             break;
49           case 356608:
50           case 357120:
51             str = "720P";
52             break;
53           default:
54             str = "不知什么清";
55             break;
56         };
57         $('<button style="margin-right:5px;">'+str+'</button>').appendTo("#xl_button_box").click(function() {
58           $("#xl_button_box button").each(function(n, e) {
59             e = $(e);
60             e.text(e.text().replace("• ", ""));
61           });
62           var _this = $(this);
63           _this.text("• "+_this.text());
64           play(n.vod_url); 
65         });
66       });
67   
68       var tmp = $("#xl_button_box button:last");
69       tmp.text("• "+tmp.text());
70       play(list[list.length-1].vod_url);
71   })
74 function play_with_mplayer(url) {
75   var ismac = (navigator.platform.indexOf("Mac") == 0);
76   var userid = url.match(/&ui=(\d+)/)[1];
77   if (ismac) {
78     return "open -a 'MPlayerX.app' --args -ExtraOptions --http-header-fields 'cookie: user="+userid+"' -url '"+url+"'";
79   } else {
80     return "mplayer -http-header-fields 'cookie: userid="+userid+"' '"+url+"'\n";
81   }