flv视怎么让他循环播放
时间:2009-04-22
来源:互联网
1. 当视频播放完毕后,它自动循环播放,
2. 将 它改成 调用外部的视频文件.
请问怎么改?谢谢....刚学习,,,试了网上的方法都没学会.希望大侠们帮个忙.谢谢
附:本人使用的是 flash 8 版本
代码:
//--------------------------------------------------------------------------// initial variables that might be useful to change
//--------------------------------------------------------------------------
// toggle for which file to play if none was set in html
// you can change the 'test.flv' in your filename
!_root.file ? file = "video.flv" : file = _root.file;
// toggle for autostarting the video
// you can change the 'true' in 'false'
!_root.autoStart ? autoStart = true: autoStart = _root.autoStart;
// toggle for the width and height of the video
// you can change them to the width and height you want
w = Stage.width;
h = Stage.height;
//--------------------------------------------------------------------------
// stream setup and functions
//--------------------------------------------------------------------------
// create and set netstream
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.setBufferTime(5);
// create and set sound object
this.createEmptyMovieClip("snd", 0);
snd.attachAudio(ns);
audio = new Sound(snd);
unmuteBut._visible = false;
//attach videodisplay
videoDisplay.attachVideo(ns);
// Retrieve duration meta data from netstream
ns.onMetaData = function(obj) {
this.totalTime = obj.duration;
};
// retrieve status messages from netstream
ns.onStatus = function(object) {
if (object.code == "NetStream.Play.Start") {
// this is invoked when the stream starts playing
// w = videoDisplay.width;
// h = videoDisplay.height;
} else if(object.code == "NetStream.Buffer.Full") {
// this is invoked when the stream is buffered
// w = videoDisplay.width;
// h = videoDisplay.height;
} else if(object.code == "NetStream.Play.Stop") {
// rewind and pause on when movie is finished
ns.seek(0);
ns.pause();
playBut._visible = true;
pauseBut._visible = false;
videoDisplay._visible = false;
playText.txt.text = "click to play";
}
};
// play the movie and hide playbutton
function playMovie() {
if(!isStarted) {
ns.play(file);
playText.txt.text = "loading ..";
isStarted = true;
} else {
ns.pause();
}
pauseBut._visible = true;
playBut._visible = false;
videoDisplay._visible = true;
}
// pause the movie and hide pausebutton
function pauseMovie() {
ns.pause();
playBut._visible = true;
pauseBut._visible = false;
};
// video click action
videoBg.onPress = function() {
if(pauseBut._visible == false) {
playMovie();
} else {
pauseMovie();
}
};
// pause button action
pauseBut.onPress = function() {
pauseMovie();
};
// play button action
playBut.onPress = function() {
playMovie();
};
// file load progress
percentBar.onEnterFrame = function() {
loaded = this._parent.ns.bytesLoaded;
total = this._parent.ns.bytesTotal;
if (loaded == total && loaded>1000) {
percentBar._width = bw;
delete this.onEnterFrame;
} else {
percentBar._width = int(bw*loaded/total);
}
};
// play progress function
progressBar.onEnterFrame = function() {
this._width = bw*ns.time/ns.totalTime;
};
// start playhead scrubbing
centerBg.onPress = function() {
this.onEnterFrame = function() {
scl = this._xmouse*this._xscale/bw/100;
ns.seek(scl*ns.totalTime);
};
};
// stop playhead scrubbing
centerBg.onRelease = centerBg.onReleaseOutside = function () {
delete this.onEnterFrame;
pauseBut._visible == false ? videoDisplay.pause() : null;
};
// mute button action
muteBut.onPress = function() {
audio.setVolume(0);
unmuteBut._visible = true;
this._visible = false;
};
// unmute button action
unmuteBut.onPress = function() {
audio.setVolume(100);
muteBut._visible = true;
this._visible = false;
};
// set videodisplay dimensions
videoDisplay._width = videoBg._width = w;
videoDisplay._height = videoBg._height = h-20;
playText._x = w/2;
playText._y = h/2-10;
// resize the items on the left ..
leftBg._x = 0;
leftBg._y = h-20;
playBut._x = pauseBut._x = 12;
playBut._y = pauseBut._y = h-10;
// resize the items in the middle ..
centerBg._x = percentBar._x = progressBar._x = backBar._x = 21;
centerBg._y = h - 20;
percentBar._y = progressBar._y = h - 12;
bw = centerBg._width = percentBar._width = progressBar._width = w - 42;
// and resize the ones on the right ..
rightBg._x = w - 21;
rightBg._y = h - 20;
muteBut._x = unmuteBut._x = w - 11;
muteBut._y = unmuteBut._y = h - 10;
if (autoStart == true) {
playMovie();
} else {
pauseBut._visible = false;
imageStr = substring(file,0,file.length-3)+"jpg";
imageClip.loadMovie(imageStr);
}
作者: dnaliang 发布时间: 2009-04-22



作者: transformer2 发布时间: 2009-04-22

你这是AS2.0啊,刚开始学就是3.0版本的,没学过2.0,抱歉
作者: YuBoXuan 发布时间: 2009-04-22
作者: dnaliang 发布时间: 2009-04-22
if(object.code == "NetStream.Play.Stop") {这就表示播放完了
// rewind and pause on when movie is finished
ns.seek(0);
ns.pause();//加个参数false 它就从头播放了。加个return 以下代码就不执行了
2. 将 它改成 调用外部的视频文件. //它本身就是播放外部视频文件
作者: flash023 发布时间: 2009-04-22
引用:
原帖由 flash023 于 2009-4-22 12:48 发表1. 当视频播放完毕后,它自动循环播放,//
if(object.code == "NetStream.Play.Stop") {这就表示播放完了
// rewind and pause on when movie is finished
ns.seek(0);
ns.pause();//加个 ...
具体怎么加,我加了但不对?
另外,我知道他是播放外部的flv文件,我的意思是调用外部一个文件或者flashvars变量传进去,在flash里通过接收这个文件或变量来读取flv文件,因为我每个页面读取的flv 不一样。我不能1个flv就放一个播放器吧。
作者: dnaliang 发布时间: 2009-04-27
a.b.play();
var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void {
a.b.play("1_1.flv");
a.b.play();
};
a.b.addEventListener("complete", listenerObject);
作者: suyaoqian 发布时间: 2011-07-05
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28