|
网页APlayerUI 自动播放 请大家再修改修改完美完美 网页如下
- <html>
- <head>
- <meta http-equiv="Content-Type" CONTENT="text/html; charset=UTF8">
- <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
- <title>迅雷Aplayer播放器</title>
- <style type="text/css">html, body { height:100%; margin:0; padding:0; overflow:hidden; text-align:center; background:#000000; }</style>
- <!--//
- 使用说明:
- aplayer.html?videourl=http://fuli.zuida-youku-le.com/20170815/7SNOtxEL/index.m3u8
- aplayer.html?videourl=视频地址(mp4 flv m3u8 rtmp rmvb mkv ...... 等几乎所有格式)
- 支持mp4 flv m3u8 rtmp rmvb mkv ...... 等几乎所有格式
- -->
- </head>
- <body style="margin:0px;padding:0px;">
- <script type="text/javascript">
- function getUrlParam(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
- var r = window.location.search.substr(1).match(reg); //匹配目标参数
- if(r != null) return unescape(r[2]);
- return null; //返回参数值
- }
- var videoUrl =getUrlParam('videourl');
- </script>
- <div id="left" style="position:absolute;top:40px;left:0px;width:100%;height:100%;z-index:100;color:#ffffff;font-size:14px;">
- 无法演示, <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>
- </div>
- <object
- id="Player"
- width="100%"
- height="100%"
- classid="CLSID:23A860E9-0C41-4E01-9206-D3FC0E413645"
- style="left:20; top:90;" VIEWASTEXT>
- <embed
- id="Player_FF"
- name="Player"
- type="application/x-thunder-aplayer"
- width="100%"
- height="100%"
- clsid="{23A860E9-0C41-4E01-9206-D3FC0E413645}"
- Event_OnStateChanged="OnStateChanged"
- Event_OnFlashCall="OnFlashCall"
- Event_OnFlashReadyStateChange="OnFlashReadyStateChange"
- Event_OnDocumentComplete="OnDocumentComplete"
- Event_OnPictureLBtnDown="OnPictureLBtnDown"
- Event_OnOpenSucceeded="OnOpenSucceeded">
- </embed>
- </object>
- <script type="text/javascript">
- var EventUtil =
- {
- addHandler: function(element, type, handler)
- {
- if (element.addEventListener) {
- element.addEventListener(type, handler, false);
- }
- else {
- element.attachEvent("on" + type, handler);
- }
- },
-
- removeHandler: function(element, type, handler)
- {
- if (element.removeEventListener) {
- element.removeEventListener(type, handler, false);
- }
- else {
- element.detachEvent("on" + type, handler);
- }
- }
- };
- </script>
-
- <script type="text/javascript">
- var player = null;
- var Aplayer = null;
-
- var ID1 = null;
- var flash1 = null;
-
- var ID2 = null;
- var flash2 = null;
-
- var bShow = true;
- var bEnable = false;
-
- var position = null;
- var duration = null;
-
- var unloadhandler = function()
- {
- if (ID1 != null) {
- player.RemoveElement(ID1);
- ID1 = null;
- flash1 = null;
- }
-
- if (ID2 != null) {
- player.RemoveElement(ID2);
- ID2 = null;
- flash2 = null;
- }
-
- };
-
- var loadhandler = function()
- {
- player = GetElementById("Player");
- Aplayer = player.GetAPlayerObject();
- if(player == null || Aplayer == null)
- return;
-
- player.ShowDefaultControlBar(true, 40);
- ID1 = Aplayer.Open(videoUrl);
- player.SetElementPosition(ID1, 7, 0, 0, 100, 100);
- player.SetElementVisible(ID1, true);
- player.ShowDefaultControlBar(bShow, 40);
- player.SetElementVisible(ID1, true);
- flash1 = player.GetElementObject(ID1);
- };
- function MillisecondToText(ms) {
- var s = ms / 1000;
- ms = ms % 1000;
- var h = s / 3600;
- s = s % 3600;
- var m = s / 60;
- s = s % 60;
- h = Math.floor(h);
- m = Math.floor(m);
- s = Math.floor(s);
- var text = "";
- if (h > 0 && h < 10)
- text = "0" + h + ":";
- if (m >= 0 && m < 10)
- text = text + "0" + m + ":";
- else
- text = text + m + ":";
- if (s >= 0 && s < 10)
- text = text + "0" + s;
- else
- text = text + s;
- return text;
- }
-
- function UpdateTime()
- {
- var text = null;
- if (Aplayer != null)
- {
- if (Aplayer.GetState() == 5)
- {
- position = Aplayer.GetPosition();
- position = MillisecondToText(position);
- var p = Aplayer.GetBufferProgress();
-
- if (p == -1)
- text = position + " / " + duration;
- else
- text = position + " / " + duration + " (正在缓冲..." + p + "%)";
-
- var para = "<invoke name=\"callflash\" returntype=\"xml\"><arguments><string>";
- para = para + text;
- para = para + "</string></arguments></invoke>";
- player.CallFlashFunction(ID1, para);
- }
- else
- {
- var nResult = Aplayer.GetConfig(7);
- if(nResult != 0 && nResult != 1)
- text= "播放失败, 错误码 = " + nResult;
- else
- text = "";
-
- }
- }
- setTimeout(function () { UpdateTime(); }, 1000);
- }
- UpdateTime();
-
- function OnOpenSucceeded() {
- var nDuration = Aplayer.GetDuration();
- duration = MillisecondToText(nDuration);
- }
-
- function OnDocumentComplete(nID, URL)
- {
- //alert("ID="+nID+", 网页 "+URL+" 加载完成!");
- }
-
- /*function thisMovie(movieName)
- {
- if (navigator.appName.indexOf("Microsoft") != -1) {
- return window[movieName];
- }
- else {
- return document[movieName];
- }
- }*/
-
- function GetElementById(Id)
- {
- if (navigator.appName.indexOf("Microsoft") != -1) {
- return document.getElementById(Id);
- }
- else {
- return document.getElementById(Id+"_FF");
- }
- }
-
- function ShowDefaultControlBar()
- {
- player.ShowDefaultControlBar(bShow, 40);
- if (bShow == false) {
- player.SetElementVisible(ID1, true);
- }
- else if (ID1 != null) {
- player.SetElementVisible(ID1, false);
- }
-
- bShow = !bShow;
- }
-
- function SetForeground()
- {
- if (ID2 != null) {
- var result = player.SetForegroundElement(ID2);
- }
- }
-
- /*function eventListener()
- {
- alert('receive_player: '+document.domain);
- }*/
-
- EventUtil.addHandler(window, "load", loadhandler);
- EventUtil.addHandler(window, "unload", unloadhandler);
-
- function showflash()
- {
- player.SetElementVisible(ID2, true);
- }
-
- function hideflash()
- {
- player.SetElementVisible(ID2, false);
- }
-
-
- function OnStateChanged(oldState, newState)
- {
- switch (newState)
- {
- case 0: // PS_READY
- case 3: // PS_PAUSED
- showflash();
- break;
-
- case 5: // PS_PLAY
- hideflash();
- break;
- }
- }
-
- function OnPictureLBtnDown(nID)
- {
- //alert("ID=" + nID + ", 没有美女看,不用点啦!");
- //player.SetElementVisible(ID3, false);
- }
-
- function OnFlashReadyStateChange(nID, newState)
- {
- //alert("event=OnReadyStateChange, flashID=" + nID + ", state=" + newState);
- }
- </script>
- </body>
- </html>
调用方法: aplayer.html?videourl=视频地址
|