• 82819阅读
  • 404回复

网页调用 APlayerUI 自动播放 [复制链接]

上一主题 下一主题
离线mshuking
 

只看楼主 倒序阅读 使用道具 楼主  发表于: 2015-10-04
网页APlayerUI  自动播放
请大家再修改修改完美完美
网页如下


  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" CONTENT="text/html; charset=UTF8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
  5. <title>迅雷Aplayer播放器</title>
  6. <style type="text/css">html, body { height:100%; margin:0; padding:0; overflow:hidden; text-align:center; background:#000000; }</style>
  7. <!--//
  8. 使用说明:
  9. aplayer.html?videourl=http://fuli.zuida-youku-le.com/20170815/7SNOtxEL/index.m3u8
  10. aplayer.html?videourl=视频地址(mp4 flv m3u8 rtmp rmvb mkv ...... 等几乎所有格式)
  11. 支持mp4 flv m3u8 rtmp rmvb mkv ...... 等几乎所有格式
  12. -->
  13. </head>
  14. <body style="margin:0px;padding:0px;">
  15.         <script type="text/javascript">
  16.             function getUrlParam(name) {
  17.                 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
  18.                 var r = window.location.search.substr(1).match(reg); //匹配目标参数
  19.                 if(r != null) return unescape(r[2]);
  20.                 return null; //返回参数值
  21.             }
  22.             var videoUrl =getUrlParam('videourl');
  23.         </script>
  24. <div id="left" style="position:absolute;top:40px;left:0px;width:100%;height:100%;z-index:100;color:#ffffff;font-size:14px;">
  25. 无法演示, <a href='http://aplayer.open.xunlei.com/' target="_blank">迅雷APlayer</a> 功能未安装! 请下载 <a href='http://aplayer.open.xunlei.com/APlayerSDK.zip'>APlayerSDK</a> 解压后,使用其中的 install.bat 安装。</br></br>也可以下载安装<a href='http://video.xunlei.com/pc.html' target="_blank">迅雷影音</a>或<a href='http://www.kankan.com/app/xmp.html' target="_blank">迅雷看看</a>,安装后即可正常使用!</br></br>
  26. </div>
  27.           <object
  28.             id="Player"
  29.             width="100%"
  30.             height="100%"
  31.             classid="CLSID:23A860E9-0C41-4E01-9206-D3FC0E413645"
  32.             style="left:20; top:90;" VIEWASTEXT>
  33.             <embed
  34.                 id="Player_FF"
  35.                 name="Player"
  36.                 type="application/x-thunder-aplayer"
  37.                 width="100%"
  38.                 height="100%"
  39.                 clsid="{23A860E9-0C41-4E01-9206-D3FC0E413645}"
  40.                 Event_OnStateChanged="OnStateChanged"
  41.                 Event_OnFlashCall="OnFlashCall"
  42.                 Event_OnFlashReadyStateChange="OnFlashReadyStateChange"
  43.                 Event_OnDocumentComplete="OnDocumentComplete"
  44.                 Event_OnPictureLBtnDown="OnPictureLBtnDown"
  45.                 Event_OnOpenSucceeded="OnOpenSucceeded">
  46.             </embed>
  47.           </object>
  48.           <script type="text/javascript">
  49.             var EventUtil =
  50.             {
  51.                 addHandler: function(element, type, handler)
  52.                 {
  53.                     if (element.addEventListener) {
  54.                         element.addEventListener(type, handler, false);
  55.                     }
  56.                     else {
  57.                         element.attachEvent("on" + type, handler);
  58.                     }
  59.                 },
  60.                 
  61.                 removeHandler: function(element, type, handler)
  62.                 {
  63.                     if (element.removeEventListener) {
  64.                         element.removeEventListener(type, handler, false);
  65.                     }
  66.                     else {
  67.                         element.detachEvent("on" + type, handler);
  68.                     }
  69.                 }
  70.             };
  71.           </script>
  72.           
  73.           <script type="text/javascript">
  74.             var player = null;
  75.             var Aplayer = null;
  76.             
  77.             var ID1 = null;
  78.             var flash1 = null;
  79.             
  80.             var ID2 = null;
  81.             var flash2 = null;
  82.             
  83.             var bShow = true;
  84.             var bEnable = false;
  85.             
  86.             var position = null;
  87.             var duration = null;
  88.             
  89.             var unloadhandler = function()
  90.             {
  91.                 if (ID1 != null) {
  92.                     player.RemoveElement(ID1);
  93.                     ID1 = null;
  94.                     flash1 = null;
  95.                 }
  96.                 
  97.                 if (ID2 != null) {
  98.                     player.RemoveElement(ID2);
  99.                     ID2 = null;
  100.                     flash2 = null;
  101.                 }
  102.                 
  103.             };
  104.             
  105.             var loadhandler = function()
  106.             {
  107.                 player = GetElementById("Player");
  108.                 Aplayer = player.GetAPlayerObject();
  109.                 if(player == null || Aplayer == null)
  110.                     return;
  111.                 
  112.                 player.ShowDefaultControlBar(true, 40);
  113.                                 ID1 = Aplayer.Open(videoUrl);
  114.                 player.SetElementPosition(ID1, 7, 0, 0, 100, 100);
  115.                 player.SetElementVisible(ID1, true);
  116.                                 player.ShowDefaultControlBar(bShow, 40);
  117.                                 player.SetElementVisible(ID1, true);
  118.                 flash1 = player.GetElementObject(ID1);
  119.             };                        
  120.             function MillisecondToText(ms) {
  121.                 var s = ms / 1000;
  122.                 ms = ms % 1000;
  123.                 var h = s / 3600;
  124.                 s = s % 3600;
  125.                 var m = s / 60;
  126.                 s = s % 60;
  127.                 h = Math.floor(h);
  128.                 m = Math.floor(m);
  129.                 s = Math.floor(s);
  130.                 var text = "";
  131.                 if (h > 0 && h < 10)
  132.                     text = "0" + h + ":";
  133.                 if (m >= 0 && m < 10)
  134.                     text = text + "0" + m + ":";
  135.                 else
  136.                     text = text + m + ":";
  137.                 if (s >= 0 && s < 10)
  138.                     text = text + "0" + s;
  139.                 else
  140.                     text = text + s;
  141.                 return text;
  142.             }        
  143.             
  144.             function UpdateTime()
  145.             {
  146.                 var text = null;
  147.                 if (Aplayer != null)
  148.                 {
  149.                     if (Aplayer.GetState() == 5)
  150.                     {
  151.                         position = Aplayer.GetPosition();
  152.                         position = MillisecondToText(position);
  153.                         var p = Aplayer.GetBufferProgress();
  154.         
  155.                         if (p == -1)
  156.                             text = position + " / " + duration;
  157.                         else
  158.                             text = position + " / " + duration + " (正在缓冲..." + p + "%)";
  159.                             
  160.                         var para = "<invoke name=\"callflash\" returntype=\"xml\"><arguments><string>";
  161.                         para = para + text;
  162.                         para = para + "</string></arguments></invoke>";
  163.                         player.CallFlashFunction(ID1, para);
  164.                     }
  165.                     else
  166.                     {
  167.                        var nResult = Aplayer.GetConfig(7);
  168.                        if(nResult != 0 && nResult != 1)
  169.                             text= "播放失败, 错误码 = " + nResult;
  170.                        else
  171.                             text = "";
  172.                         
  173.                     }        
  174.                 }
  175.                 setTimeout(function () { UpdateTime(); }, 1000);
  176.             }
  177.             UpdateTime();
  178.             
  179.             function OnOpenSucceeded() {
  180.                 var nDuration = Aplayer.GetDuration();
  181.                 duration = MillisecondToText(nDuration);
  182.             }
  183.             
  184.             function OnDocumentComplete(nID, URL)
  185.             {
  186.                 //alert("ID="+nID+", 网页 "+URL+" 加载完成!");
  187.             }
  188.             
  189.             /*function thisMovie(movieName)
  190.             {
  191.                 if (navigator.appName.indexOf("Microsoft") != -1) {
  192.                     return window[movieName];
  193.                 }
  194.                 else {
  195.                     return document[movieName];
  196.                 }
  197.             }*/
  198.             
  199.             function GetElementById(Id)
  200.             {
  201.                 if (navigator.appName.indexOf("Microsoft") != -1) {
  202.                     return document.getElementById(Id);
  203.                 }
  204.                 else {
  205.                     return document.getElementById(Id+"_FF");  
  206.                 }
  207.             }
  208.             
  209.             function ShowDefaultControlBar()
  210.             {
  211.                 player.ShowDefaultControlBar(bShow, 40);
  212.                 if (bShow == false) {
  213.                     player.SetElementVisible(ID1, true);
  214.                 }
  215.                 else if (ID1 != null) {
  216.                     player.SetElementVisible(ID1, false);
  217.                 }
  218.                 
  219.                 bShow = !bShow;
  220.             }
  221.             
  222.             function SetForeground()
  223.             {
  224.                 if (ID2 != null) {
  225.                     var result = player.SetForegroundElement(ID2);
  226.                 }
  227.             }
  228.             
  229.             /*function eventListener()
  230.             {
  231.                 alert('receive_player: '+document.domain);
  232.             }*/
  233.             
  234.             EventUtil.addHandler(window, "load", loadhandler);
  235.             EventUtil.addHandler(window, "unload", unloadhandler);
  236.             
  237.             function showflash()
  238.             {
  239.                 player.SetElementVisible(ID2, true);
  240.             }
  241.             
  242.             function hideflash()
  243.             {
  244.                 player.SetElementVisible(ID2, false);
  245.             }
  246.             
  247.             
  248.             function OnStateChanged(oldState, newState)
  249.             {
  250.                 switch (newState)
  251.                 {
  252.                     case 0:    // PS_READY
  253.                     case 3:    // PS_PAUSED
  254.                         showflash();
  255.                         break;
  256.                     
  257.                     case 5:    // PS_PLAY
  258.                         hideflash();
  259.                         break;                
  260.                 }
  261.             }
  262.             
  263.             function OnPictureLBtnDown(nID)
  264.             {
  265.                 //alert("ID=" + nID + ", 没有美女看,不用点啦!");
  266.                 //player.SetElementVisible(ID3, false);
  267.             }
  268.             
  269.             function OnFlashReadyStateChange(nID, newState)
  270.             {
  271.                 //alert("event=OnReadyStateChange, flashID=" + nID + ", state=" + newState);
  272.             }
  273.           </script>
  274. </body>
  275. </html>


调用方法:  aplayer.html?videourl=视频地址



离线hanb

只看该作者 沙发  发表于: 2015-10-05
看看效果如何
离线a60491289

只看该作者 板凳  发表于: 2015-10-05
新手学习下
离线skipper

只看该作者 地板  发表于: 2015-10-06
前来学习 学习
离线cq1005

只看该作者 4楼 发表于: 2015-10-07
前来学习 学习
离线544580754@qq

只看该作者 5楼 发表于: 2015-10-08
kankan
离线zyzsj

只看该作者 6楼 发表于: 2015-10-08
再次回复获得播放币
离线w4792010

只看该作者 7楼 发表于: 2015-10-08
支持一下,看看
离线giason

只看该作者 8楼 发表于: 2015-10-08
让我看看是怎么一回事事
离线yypan

只看该作者 9楼 发表于: 2015-10-10
瞧瞧来了啊
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个