flowplayer的设置

本文介绍如何使用Flowplayer实现伪流式播放,并展示了详细的配置参数与自定义控制栏样式。通过JavaScript动态调整播放器布局以适应不同屏幕尺寸。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. <!doctype html>  
  2. <html>  
  3. <head>  
  4.       
  5.     <title>Basic pseudo-streaming : Flowplayer</title>  
  6.   
  7.   
  8.     <link rel="shortcut icon" href="http://flash.flowplayer.org/favicon.ico">  
  9.     <!-- standalone page styling. can be removed -->  
  10.     <style>  
  11.   
  12.     </style>  
  13.   
  14.   
  15.       
  16.       
  17.     <!-- flowplayer javascript component -->  
  18.     <script src="http://releases.flowplayer.org/js/flowplayer-3.2.12.min.js"></script>  
  19.   
  20.   
  21.     </head>  
  22.   
  23.   
  24. <body>  
  25.     <!-- player container-->  
  26. <a href="http://pseudo01.hddn.com/vod/demo.flowplayervod/flowplayer-700.flv"    class="player"  
  27.     style="display:block;width:625px;height:200px;"  
  28.     id="player">  
  29.     </a>  
  30. <input type="button" value="animate" onclick="reset()"/>  
  31. <div id="log">a</div>  
  32. <!-- this script block will install Flowplayer inside previous A tag -->  
  33. <script>  
  34. function reset() {  
  35.     animate(player, {  
  36.         bottom : 31  
  37.     });  
  38. }  
  39. var player = flowplayer(  
  40.         "player",  
  41.         "http://releases.flowplayer.org/swf/flowplayer-3.2.16.swf",  
  42.         {  
  43.             // this will enable pseudostreaming support  
  44.             plugins : {  
  45.                 pseudo : {  
  46.                     url : "http://releases.flowplayer.org/swf/flowplayer.pseudostreaming-3.2.12.swf"  
  47.                 },  
  48.   
  49.                 controls : {  
  50.                     autoHide : {  
  51.                         fullscreenOnly : true,  
  52.                         hideDelay : 2000  
  53.                     },  
  54.                     height : 30,  
  55.                     scrubber : true,  
  56.                     buttonColor : 'rgba(0, 0, 0, 0.9)',  
  57.                     buttonOverColor : '#000000',  
  58.                     backgroundGradient : 'medium',  
  59.                     backgroundColor : '#D7D7D7',  
  60.   
  61.                     sliderColor : '#2c2c2c',  
  62.                     bufferColor : '#606060',  
  63.                     progressColor : '#056e9f',  
  64.   
  65.                     sliderBorder : '1px solid #808080',  
  66.                     sliderHeight : 20,  
  67.                     volumeSliderColor : '#FFFFFF',  
  68.                     volumeBorder : '1px solid #808080',  
  69.   
  70.                     timeColor : '#000000',  
  71.                     durationColor : '#535353',  
  72.                     tooltips : {  
  73.                         buttons : true,  
  74.                         play : '播放',  
  75.                         fullscreen : '全屏',  
  76.                         fullscreenExit : '退出全屏',  
  77.                         pause : '暂停',  
  78.                         mute : '静音',  
  79.                         unmute : '取消静音'  
  80.                     }  
  81.                 }  
  82.             },  
  83.   
  84.             // clip properties  
  85.             clip : {  
  86.                 url : '/flv/flowplayer-700.flv',  
  87.   
  88.                 // make this clip use pseudostreaming plugin with "provider" property  
  89.                 provider : 'pseudo'  
  90.             },  
  91.   
  92.             onStart : function(clip) {  
  93.                 animate(this, {  
  94.                     bottom : 31  
  95.                 // 底部 31 像素的进度条  
  96.                         })  
  97.             },  
  98.             onFullscreen : function() {  
  99.                 // 如果全屏自适应的话,由于 flash 处理的延迟,会造成退出全屏是画面位置不正确  
  100.                 // 为了保证正确,可以隔大约 1 秒后调用 animate 函数  
  101.                 /**  
  102.                 animate(this, {  
  103.                     height : screen.height,  
  104.                     width : screen.width  
  105.                 })  
  106.                  **/  
  107.             },  
  108.             onFullscreenExit : function() {  
  109.                 /**  
  110.                     animate(this, {  
  111.                         bottom : 31  
  112.                     });  
  113.                  */  
  114.             },  
  115.             onBegin : function() {  
  116.             }  
  117.   
  118.         });  
  119.   
  120. function animate(player, container) {  
  121.     function copy(from, to) {  
  122.         for (key in from) {  
  123.             to[key] = from[key];  
  124.         }  
  125.     }  
  126.   
  127.     var clip = player.getClip();  
  128.     var defaultContainer = {  
  129.         height : clip.height,  
  130.         width : clip.width,  
  131.         bottom : 0,  
  132.         top : 0,  
  133.         left : 0,  
  134.         right : 0,  
  135.         getRatio : function() {  
  136.             return (this.height - this.top - this.bottom)  
  137.                     / (this.width - this.left - this.right);  
  138.         }  
  139.     }  
  140.     copy(container, defaultContainer);  
  141.   
  142.     var metadata = clip.metaData;  
  143.     var layout = {  
  144.         height : metadata.height,  
  145.         width : metadata.width,  
  146.         bottom : 0,  
  147.         top : 0,  
  148.         left : 0,  
  149.         right : 0  
  150.     }  
  151.   
  152.     // 视频正确的显示比例  
  153.     var layoutlayoutRatio = layout.height / layout.width;  
  154.   
  155.     if (layoutRatio > defaultContainer.getRatio()) {  
  156.         // 视频画面实际比容器要高,应该在容器左右留出黑边。  
  157.         // 原始配置中的上下配置是有效的。  
  158.         layout.bottom = defaultContainer.bottom;  
  159.         layout.top = defaultContainer.top;  
  160.         layout.height = defaultContainer.height - layout.bottom - layout.top;  
  161.   
  162.         layoutlayout.width = layout.height / layoutRatio;  
  163.         layout.left = defaultContainer.left  
  164.                 + (defaultContainer.width - layout.width  
  165.                         - defaultContainer.left - defaultContainer.right) / 2;  
  166.         layout.right = defaultContainer.width - layout.width - layout.left;  
  167.     } else {  
  168.         // 视频画面实际比容器要宽,应该在容器上下留黑边  
  169.         // 原始配置中,左右大小是有效的。  
  170.         layout.width = defaultContainer.width - defaultContainer.left  
  171.                 - defaultContainer.right;  
  172.         layout.left = defaultContainer.left;  
  173.         layout.right = defaultContainer.right;  
  174.   
  175.         layout.height = layoutRatio * layout.width;  
  176.         layout.bottom = defaultContainer.bottom  
  177.                 + (defaultContainer.height - layout.height  
  178.                         - defaultContainer.bottom - defaultContainer.top) / 2;  
  179.         layout.top = defaultContainer.height - layout.height - layout.bottom;  
  180.     }  
  181.   
  182.     player.getScreen().animate(layout, 1000);  
  183.     //**  
  184.      html = "";  
  185.      for(key in layout) {  
  186.      html += key + ":" + layout[key] + ";";  
  187.      }  
  188.      AppBefore("log", html);  
  189.     // */  
  190. }  
  191.   
  192. function AppBefore(nodeId, str) {  
  193.     var node = document.getElementById(nodeId);  
  194.     var newNode = CreateNode(str);  
  195.     //如果存在双亲结点    
  196.     if (node.parentNode) {  
  197.         //insertBefore(newchild,refchild)  说明:newchild(插入的新结点) refchild(将新结点插入到此结点前)    
  198.         node.parentNode.insertBefore(newNode, node);  
  199.     }  
  200. }  
  201.   
  202. function CreateNode(str) {  
  203.     //创建新div    
  204.     var NewDiv = document.createElement("div");  
  205.     //对div设置 id属性    
  206.     NewDiv.id = "dd";  
  207.     //创建div内加入的内容    
  208.     var NewText = document.createTextNode(str);  
  209.     //追加一个新的子结点    
  210.     NewDiv.appendChild(NewText);  
  211.     //返回新创建结点数据    
  212.     return NewDiv;  
  213. }  
  214. </script>  
  215.   
  216.   
  217. </body>  
  218.   
  219.   
  220. </html> 
### Flowplayer Web 视频播放器源码下载及相关信息 Flowplayer 是一个基于 GPL 3 许可证的开源 WEB 视频播放器,支持多种流媒体格式和自定义配置[^2]。以下为关于 Flowplayer 源码下载及使用的相关信息: #### 源码下载 Flowplayer 的官方版本可以通过其官方网站获取最新稳定版源码[^1]。此外,也可以通过第三方平台下载测试项目源文件,例如 优快云 提供的测试项目源文件链接:[http://download.youkuaiyun.com/detail/u010989191/9513711](http://download.youkuaiyun.com/detail/u010989191/9513711)。 #### 使用方法 以下是使用 Flowplayer 的基本步骤和代码示例: - **加载 Flowplayer.js** 在 HTML 文件的 `<head>` 部分引入 Flowplayer 的 JavaScript 文件: ```html <script src="path/to/flowplayer.js"></script> ``` - **XHTML 结构** 在需要嵌入播放器的位置添加如下代码: ```html <a href="/Video/story.flv" style="display: block; width: 670px; height: 450px" id="tl_player"></a> ``` - **JavaScript 调用** 在页面底部调用 Flowplayer 函数以初始化播放器: ```javascript flowplayer("tl_player", "/js/flowplayer/flowplayer-3.2.12.swf"); ``` 对于更高级的配置,可以使用 JSON 格式进行设置。例如,指定视频地址、自动播放等参数: ```javascript flowplayer("player2", "flowplayer-3.2.7.swf", { clip: { url: "flowplayer.flv", autoPlay: false, autoBuffering: true } }); ``` #### RTMP 流媒体支持 如果需要支持 RTMP 协议,可以在初始化时添加 `plugins` 参数: ```javascript flowplayer("player", "flowplayer-3.2.8.swf", { clip: { url: 'home', provider: 'rtmp', live: true }, plugins: { rtmp: { url: 'flowplayer.rtmp-3.2.8.swf', netConnectionUrl: 'rtmp://192.168.1.110:1935/live' } } }); ``` #### 注意事项 在使用 Flowplayer 时,请确保遵循 GPL 3 许可证的要求[^2]。此外,由于部分版本可能依赖 Flash 技术,建议选择支持 HTML5 的最新版本以适应现代浏览器环境[^4]。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值