自己制作FLV播放器

制作步骤:
  1.新建一个FLASH文档,设置舞台大小:300*260。
  2.将组件MediaController和MediaDisplay拖入舞台,然后从舞台上删除。这样做的目的是将这两个组件载入库中,为接下来用attachMovie()方法将MediaController和MediaDisplay组件载入舞台做好准备。


  3.新建一层,命名为function。在该层的第一帧上输入如下AS代码:
function init(){
flagNum = 1;
//播放影片的标示
flvNum = 0;
attachController();
};
//将MediaController和MediaDisplay组件载入舞台并初始化
function attachController(){
//将MediaDisplay组件载入舞台并给定义实例名 “flvContainer” + flagNum
_root.attachMovie(“MediaDisplay”,”flvContainer” + flagNum,2);
//设置组件初始参数
with(_root[“flvContainer” + flagNum]){
_x = 0;
_y = 0;
setMedia(myArray[flvNum],”FLV”);//设置播放格式可以mp3等
}
//将MediaController组件载入舞台并给定义实例名 “flvController” + flagNum
_root.attachMovie(“MediaController”,”flvController” + flagNum,1);
//设置组件初始参数
with(_root[“flvController” + flagNum]){
_x = 0;
_y = 190;
activePlayControl = false;
controllerPolicy = “on”;
//将MediaController和MediaDisplay组件相关联
associateDisplay(_root[“flvContainer” + flagNum]);
};
};
function playNext(){
//将MediaController和MediaDisplay组件从舞台上删除
_root[“flvController” + flagNum].removeMovieClip();
_root[“flvContainer” + flagNum].removeMovieClip();
flagNum += 1;
flvNum += 1;
//如果播放到影片的最后一首,将flvNum = 0,意为将从头开始播放
if(flvNum == flvTotal) flvNum = 0;
//重新载入MediaController和MediaDisplay组件,并给一新的实例名
attachController();
//因为每播放完一个影片后MediaController和MediaDisplay组件从舞台上被卸载
//然后又重新载入MediaController和MediaDisplay组件并给了另外一个实例名
_root[“flvContainer” + flagNum].addEventListener(“complete”, myListener);
};

4.新建一层,命名为action,在该层第一帧输入一下AS代码:

stop();
//数组myArray用来存储 载入的XML文档中的影片名称
var myArray = new Array();
//影片的总数
var flvTotal:Number;
var myXml = new XML();
myXml.ignoreWhite = true;
myXml.load(“list.xml”);
myXml.onLoad = function() {
var e = myXml.firstChild.childNodes;
flvTotal = e.length;
for (var i = 0; i myArray.push(e[i].attributes[“title”]);
}
init();
_root[“flvContainer”+flagNum].addEventListener(“complete”, myListener);
};
var myListener = new Object();
myListener.complete = function(eventObject) {
playNext();
};

用记事本写入下面内容作为播放列表,保存为list.xml:

<?xml version="1.0" encoding="utf-8" ?>
<flvLists>
<item title="1.flv" />
<item title="2.flv" />
<item title="3.flv" />
<item title="4.flv" />
</flvLists>

制作完成。OK

随机文章:

1、如何用CSS层叠样式表控制鼠标显示的样式
https://www.onexin.net/latest/%e5%a6%82%e4%bd%95%e7%94%a8css%e5%b1%82%e5%8f%a0%e6%a0%b7%e5%bc%8f%e8%a1%a8%e6%8e%a7%e5%88%b6%e9%bc%a0%e6%a0%87%e6%98%be%e7%a4%ba%e7%9a%84%e6%a0%b7%e5%bc%8f/

2、如何将网站批量提交搜索引擎?
https://www.onexin.net/resource/how-do-i-submit-a-site-bulk-search-engine/

3、中国天气数据php版
https://www.onexin.net/languages/chinese-weather-data-in-php-version/

4、[个人潜能7B]不再自我破坏财务
https://www.onexin.net/potential/neuro-associative-conditioning/personal-potentials-7b-is-no-longer-self-destruction-of-the-financial/

5、网页制作之常用CSS缩写语法总结
https://www.onexin.net/latest/%e7%bd%91%e9%a1%b5%e5%88%b6%e4%bd%9c%e4%b9%8b%e5%b8%b8%e7%94%a8css%e7%bc%a9%e5%86%99%e8%af%ad%e6%b3%95%e6%80%bb%e7%bb%93/

转载请注明出处:https://www.onexin.net/latest/%e8%87%aa%e5%b7%b1%e5%88%b6%e4%bd%9cflv%e6%92%ad%e6%94%be%e5%99%a8/

Leave a Reply

Your email address will not be published. Required fields are marked *