no commit message
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package ckaction.player {
|
||||
import flash.net.FileReference;
|
||||
import org.bytearray.gif.player.GIFPlayer;
|
||||
import org.bytearray.gif.events.GIFPlayerEvent;
|
||||
import org.bytearray.gif.events.FrameEvent;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.net.URLRequest;
|
||||
import flash.display.MovieClip;
|
||||
public class gifPlayer {
|
||||
private var g: GIFPlayer = null;
|
||||
private var file: String = "";
|
||||
private var successFun: Function = null;
|
||||
private var loadNumber:Boolean=true;
|
||||
var m: MovieClip =null;
|
||||
public function gifPlayer(url: String, success: Function) {
|
||||
// constructor code
|
||||
successFun = success;
|
||||
file = url;
|
||||
loader();
|
||||
}
|
||||
private function loader(): void {
|
||||
g = new GIFPlayer();
|
||||
g.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
|
||||
g.addEventListener(GIFPlayerEvent.COMPLETE, completeHandler);
|
||||
g.addEventListener(FrameEvent.FRAME_RENDERED, frameHandler);
|
||||
g.load(new URLRequest(file));
|
||||
}
|
||||
private function ioErrorHandler(event: IOErrorEvent): void {
|
||||
successFun(null);
|
||||
}
|
||||
private function completeHandler(event: GIFPlayerEvent): void {}
|
||||
private function frameHandler(event: FrameEvent): void {
|
||||
var w: Number = event.frame.bitmapData.width;
|
||||
var h: Number = event.frame.bitmapData.height;
|
||||
if (loadNumber) {
|
||||
loadNumber = false;
|
||||
m = new MovieClip();
|
||||
m.addChild(g);
|
||||
m.width = w;
|
||||
m.height = h;
|
||||
successFun(m)
|
||||
}
|
||||
|
||||
}
|
||||
public function changeWH(w:int,h:int):void{
|
||||
g.width=w;
|
||||
g.height=h;
|
||||
}
|
||||
public function underChild():void{
|
||||
m.removeChild(g);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
package ckaction.player {
|
||||
import org.mangui.hls.HLS;
|
||||
import org.mangui.hls.event.HLSEvent;
|
||||
import org.mangui.hls.utils.Params2Settings;
|
||||
import org.mangui.hls.constant.HLSPlayStates;
|
||||
import org.mangui.hls.model.Level;
|
||||
import flash.display.Stage;
|
||||
import flash.events.NetStatusEvent;
|
||||
import org.mangui.hls.HLSSettings;
|
||||
import flash.media.SoundTransform;
|
||||
import ckaction.C.C;
|
||||
import flash.events.Event;
|
||||
|
||||
public class httpm3u8 {
|
||||
public var videoUrl: String = "";
|
||||
|
||||
public var netStatus: Function = null,
|
||||
streamSendOut: Function = null,
|
||||
error: Function = null; //发送流状态的函数,发送流的函数,统一用来报错的函数
|
||||
public var definitionList: Function = null,
|
||||
definitionNow: Function = null;
|
||||
public var speedFun:Function=null;
|
||||
public var stage: Stage = null;
|
||||
public var usehardwareeecoder:Boolean=false;
|
||||
private var hls: HLS = null;
|
||||
private var isClear: Boolean = false; //默认不清除
|
||||
private var vWidth: int = 0,
|
||||
vHeight: int = 0,
|
||||
time: Number = 0,
|
||||
duration: Number = 0,
|
||||
bytesTotal: int = 0,
|
||||
bytesLoaded: int = 0;
|
||||
private var urlArr: Array = [];
|
||||
public function httpm3u8() {
|
||||
// constructor code
|
||||
}
|
||||
public function load(eve: Boolean = true): void {
|
||||
if (C.CONFIG["flashvars"]["debug"]) {
|
||||
org.mangui.hls.HLSSettings.logInfo = true;
|
||||
org.mangui.hls.HLSSettings.logDebug2 = true;
|
||||
org.mangui.hls.HLSSettings.logWarn = true;
|
||||
org.mangui.hls.HLSSettings.logError = true;
|
||||
}
|
||||
org.mangui.hls.HLSSettings.maxBufferLength = C.CONFIG["config"]["m3u8MaxBufferLength"];
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
hls = new HLS();
|
||||
hls.stage = stage;
|
||||
hls.addEventListener(HLSEvent.PLAYBACK_COMPLETE, completeHandler);
|
||||
hls.addEventListener(HLSEvent.ERROR, errorHandler);
|
||||
hls.addEventListener(HLSEvent.MANIFEST_LOADED, manifestHandler);
|
||||
hls.addEventListener(HLSEvent.MEDIA_TIME, mediaTimeHandler);
|
||||
hls.addEventListener(HLSEvent.PLAYBACK_STATE, stateHandler);
|
||||
hls.addEventListener(HLSEvent.FRAGMENT_LOADING, fragmentHandler);
|
||||
hls.addEventListener(HLSEvent.FRAGMENT_PLAYING, fragmentPlayingHandler);
|
||||
hls.addEventListener(HLSEvent.ID3_UPDATED, ID3Handler);
|
||||
hls.addEventListener(HLSEvent.FRAGMENT_LOADED, fragmentLoadedHandler);
|
||||
hls.addEventListener(HLSEvent.LOADED_BYTES,loadedBytesHandler);
|
||||
hls.stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
|
||||
try{
|
||||
hls.stream.useHardwareDecoder=usehardwareeecoder;
|
||||
}
|
||||
catch(error:Event){
|
||||
|
||||
}
|
||||
hls.load(videoUrl);
|
||||
}
|
||||
private function fragmentLoadedHandler(event: HLSEvent): void {
|
||||
if (bytesLoaded < bytesTotal) {
|
||||
bytesLoaded++;
|
||||
}
|
||||
}
|
||||
private function loadedBytesHandler(event: HLSEvent): void {
|
||||
trace("加载量:",event.loadedBytes);
|
||||
speedFun(event.loadedBytes);
|
||||
}
|
||||
private function completeHandler(event: HLSEvent): void {
|
||||
//trace("hls:completeHandler", event);
|
||||
}
|
||||
private function errorHandler(event: HLSEvent): void {
|
||||
//trace("hls:errorHandler", event);
|
||||
error(C.CONFIG["language"]["error"]["streamNotFound"]);
|
||||
clear();
|
||||
}
|
||||
private function manifestHandler(event: HLSEvent): void { //可以播放了
|
||||
trace("可以进行播放====");
|
||||
var i: int = 0;
|
||||
var len: int = event.levels.length;
|
||||
while (i < len) {
|
||||
//trace("==",event.levels[i].url);
|
||||
urlArr.push(event.levels[i].url);
|
||||
i++;
|
||||
}
|
||||
trace(event.levels[hls.startLevel].url);
|
||||
if (urlArr.length > 1) {
|
||||
definitionList(urlArr, hls.startLevel);
|
||||
}
|
||||
bytesTotal = event.levels[hls.startLevel].fragments.length;
|
||||
if (isClear) {
|
||||
return;
|
||||
}
|
||||
hls.stream.play();
|
||||
duration = event.levels[hls.startLevel].duration;
|
||||
netStatus("NetConnection.Connect.Success");
|
||||
}
|
||||
private function mediaTimeHandler(event: HLSEvent): void {
|
||||
//监听时间改变
|
||||
time = Math.max(0, event.mediatime.position);
|
||||
|
||||
}
|
||||
private function stateHandler(event: HLSEvent) {
|
||||
if (event.level < urlArr.length - 1) {
|
||||
definitionNow(event.level);
|
||||
}
|
||||
switch (event.state) {
|
||||
case HLSPlayStates.PLAYING_BUFFERING:
|
||||
break;
|
||||
case HLSPlayStates.PAUSED_BUFFERING:
|
||||
break;
|
||||
case HLSPlayStates.PLAYING:
|
||||
break;
|
||||
case HLSPlayStates.PAUSED:
|
||||
break;
|
||||
case HLSPlayStates.IDLE: //播放结束
|
||||
netStatus("NetStream.Play.Stop");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
private function fragmentHandler(event: HLSEvent): void {
|
||||
//trace("hls:fragmentHandler", event.playMetrics)
|
||||
}
|
||||
private function ID3Handler(event: HLSEvent) {
|
||||
//trace("hls:ID3Handler", event);
|
||||
}
|
||||
private function netStatusHandler(event: NetStatusEvent): void {
|
||||
//trace("========",event.info.code);
|
||||
netStatus(event.info.code);
|
||||
}
|
||||
private function fragmentPlayingHandler(event: HLSEvent): void {
|
||||
if (vWidth == 0 && vHeight == 0) {
|
||||
vWidth = event.playMetrics.video_width;
|
||||
vHeight = event.playMetrics.video_height;
|
||||
hls.stream.pause();
|
||||
var metaDataObj: Object = {
|
||||
netStream: hls.stream,
|
||||
type: "[object HLSNetStream]",
|
||||
metaData: {
|
||||
width: vWidth,
|
||||
height: vHeight,
|
||||
duration: duration,
|
||||
bytesTotal: bytesTotal
|
||||
|
||||
}
|
||||
};
|
||||
//模拟发送监听状态
|
||||
netStatus("NetStream.Play.Start");
|
||||
streamSendOut(metaDataObj);
|
||||
}
|
||||
trace("hls:fragmentPlayingHandler", event);
|
||||
|
||||
}
|
||||
public function videoVolume(val: Number = 0): void { //修改音量
|
||||
var v: SoundTransform = hls.stream.soundTransform;
|
||||
v.volume = val;
|
||||
if (hls.stream) {
|
||||
hls.stream.soundTransform = v;
|
||||
}
|
||||
|
||||
}
|
||||
public function videoSeek(time: Number = 0): void {
|
||||
if (hls.stream) {
|
||||
var n: int = time/(duration / bytesTotal);
|
||||
if (bytesLoaded < n) {
|
||||
bytesLoaded = n;
|
||||
}
|
||||
hls.stream.seek(time);
|
||||
}
|
||||
}
|
||||
//提供给外部调用使用
|
||||
public function getTime(): Number {
|
||||
return time;
|
||||
}
|
||||
public function getDuration(): Number {
|
||||
return duration;
|
||||
}
|
||||
public function getBytesLoaded(): Number {
|
||||
return bytesLoaded;
|
||||
}
|
||||
public function getBytesTotal(): Number {
|
||||
return bytesTotal;
|
||||
}
|
||||
public function getBufferTime(): Number {
|
||||
if (hls.stream != null) {
|
||||
return hls.stream.bufferTime;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public function getBufferLength(): Number {
|
||||
if (hls.stream != null) {
|
||||
return hls.stream.bufferLength;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public function videoPlay(): void {
|
||||
trace("==执行了m3u8-videoPlay");
|
||||
if (hls.stream != null) {
|
||||
hls.stream.resume();
|
||||
}
|
||||
}
|
||||
public function videoPause(): void {
|
||||
if (hls.stream != null) {
|
||||
hls.stream.pause();
|
||||
}
|
||||
}
|
||||
//提供给外部调用结束
|
||||
public function clear(): void {
|
||||
isClear = true;
|
||||
if (hls) {
|
||||
hls.removeEventListener(HLSEvent.PLAYBACK_COMPLETE, completeHandler);
|
||||
hls.removeEventListener(HLSEvent.ERROR, errorHandler);
|
||||
hls.removeEventListener(HLSEvent.MANIFEST_LOADED, manifestHandler);
|
||||
hls.removeEventListener(HLSEvent.MEDIA_TIME, mediaTimeHandler);
|
||||
hls.removeEventListener(HLSEvent.PLAYBACK_STATE, stateHandler);
|
||||
hls.removeEventListener(HLSEvent.FRAGMENT_LOADING, fragmentHandler);
|
||||
hls.removeEventListener(HLSEvent.FRAGMENT_PLAYING, fragmentPlayingHandler);
|
||||
hls.removeEventListener(HLSEvent.ID3_UPDATED, ID3Handler);
|
||||
hls.removeEventListener(HLSEvent.FRAGMENT_LOADED, fragmentLoadedHandler);
|
||||
hls.removeEventListener(HLSEvent.LOADED_BYTES,loadedBytesHandler);
|
||||
hls.stream.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
|
||||
hls.stream.close();
|
||||
hls = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
package ckaction.player {
|
||||
import ckaction.act.script;
|
||||
import ckaction.act.timeInterval;
|
||||
import ckaction.C.C;
|
||||
import ckaction.act.des;
|
||||
import ckaction.act.timeOut;
|
||||
import ckaction.process.getVideoMeta;
|
||||
|
||||
public class httpmerge {
|
||||
public var videoUrl: Array = [];
|
||||
public var netStatus: Function = null,
|
||||
streamSendOut: Function = null,
|
||||
error: Function = null; //发送流状态的函数,发送流的函数,统一用来报错的函数
|
||||
public var speedFun:Function=null;
|
||||
private var timeTotal: Number = 0,
|
||||
bytesTotal: Number = 0; //总时间,总字节
|
||||
private var timeArr: Array = [],
|
||||
bytesArr: Array = []; //时间数组,字节数组
|
||||
//private var DRAG:String="";
|
||||
private var isClear: Boolean = false; //默认不清除
|
||||
private var nowVolume: Number = 0;
|
||||
private var playNum: int = 0; //当前播放的视频编号
|
||||
private var loadNum: int = 0; //加载编号
|
||||
private var bytesMax:int=0;//已加载的编号最大编号
|
||||
private var nsArr: Array = [],
|
||||
streamArr: Array = [];
|
||||
private var loadedArr: Array = []; //是否已加载0=没有加载,1=正在加载,2=已加载
|
||||
private var interBytes: timeInterval = null;
|
||||
private var loadFrist:Boolean=true;
|
||||
private var loadNext: int = 0;
|
||||
private var playSeek: Number = -1; //默认要跳转的秒数,只有在跳转到新时间而相应的视频段没有加载的情况下才需要用到
|
||||
private var getMeta:getVideoMeta=null;
|
||||
public function httpmerge() {
|
||||
// constructor code
|
||||
//DRAG=C.CONFIG["flashvars"]["drag"];
|
||||
}
|
||||
public function load(): void {
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
trace("新建了一个视频");
|
||||
//script.traceObject(videoUrl);
|
||||
loadNext = C.CONFIG["config"]["loadNext"];
|
||||
var tempUrl:Object=videoUrl[0];
|
||||
if(!tempUrl.hasOwnProperty("duration") || !tempUrl.hasOwnProperty("bytesTotal")){
|
||||
getMeta=new getVideoMeta(videoUrl,loadUrl,speed);
|
||||
}
|
||||
else{
|
||||
loadUrl()
|
||||
}
|
||||
}
|
||||
private function speed(t:int=0):void{
|
||||
speedFun(Math.ceil(t*100/videoUrl.length));
|
||||
}
|
||||
private function loadUrl(ele:Array=null):void{
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
if(ele!=null){
|
||||
videoUrl=ele;
|
||||
}
|
||||
for (var i: int = 0; i < videoUrl.length; i++) {
|
||||
var stream: httpstream = new httpstream();
|
||||
if(C.CONFIG["flashvars"]["unescape"]){
|
||||
stream.videoUrl = unescape(des.getString(videoUrl[i]["file"]));
|
||||
}
|
||||
else{
|
||||
stream.videoUrl = des.getString(videoUrl[i]["file"]);
|
||||
}
|
||||
|
||||
stream.netStatus = NetStatus;
|
||||
stream.streamSendOut = StreamSendOut;
|
||||
stream.error = errorNow;
|
||||
stream.NUM = i;
|
||||
loadedArr.push(0);
|
||||
nsArr.push(stream);
|
||||
streamArr.push(null);
|
||||
//计算总时间
|
||||
timeArr.push(Number(videoUrl[i]["duration"]));
|
||||
bytesArr.push(Number(videoUrl[i]["bytesTotal"]));
|
||||
}
|
||||
nsArr[0].load();
|
||||
loadedArr[0]=1;
|
||||
timeTotal = script.arrSum(timeArr);
|
||||
bytesTotal = script.arrSum(bytesArr);
|
||||
if (loadNext == 0) {
|
||||
loadNext = nsArr.length;
|
||||
}
|
||||
}
|
||||
private function NetStatus(status: String, n: int = 0) {
|
||||
//trace(status);
|
||||
//trace("接爱到状态",n,status,new Date().getMilliseconds());
|
||||
|
||||
//trace("httpmerge",status);
|
||||
switch (status) {
|
||||
case "NetStream.Play.Stop": //播放完毕
|
||||
trace(playNum,n);
|
||||
if (playNum == n && playNum < nsArr.length - 1) { //说明是播放结束
|
||||
nsArr[playNum].videoPause();
|
||||
trace("开始请求下一段",new Date().getMilliseconds());
|
||||
newPlay(playNum+1, 0); //播
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (playNum == n) {
|
||||
if (n == 0) {
|
||||
if (status != "NetStream.Play.Stop") {
|
||||
netStatus(status);
|
||||
}
|
||||
}
|
||||
else if (n < nsArr.length - 1) {
|
||||
if (status != "NetStream.Play.Stop" && status != "NetStream.Play.Start") {
|
||||
netStatus(status);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (status != "NetStream.Play.Start") {
|
||||
netStatus(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private function StreamSendOut(obj: Object, n: int = 0): void {
|
||||
if (isClear) {
|
||||
return;
|
||||
}
|
||||
if (streamArr[n] == null) {
|
||||
streamArr[n] = obj;
|
||||
}
|
||||
bytesArr[n] = obj["metaData"]["bytesTotal"]; //更新当前段的字节
|
||||
if (loadFrist) {
|
||||
//trace("playSeek",playSeek);
|
||||
loadFrist=false;
|
||||
obj["metaData"]["duration"] = timeTotal;
|
||||
obj["metaData"]["bytesTotal"] = bytesTotal;
|
||||
streamSendOut(obj);
|
||||
}
|
||||
else {
|
||||
if (playNum == n) {
|
||||
streamSendOut(obj);
|
||||
//trace("playSeek",playSeek);
|
||||
if(playSeek>-1){
|
||||
nsArr[playNum].videoSeek(playSeek);
|
||||
|
||||
playSeek=-1;
|
||||
}
|
||||
videoVolume(nowVolume);
|
||||
}
|
||||
else {
|
||||
nsArr[n].videoPause();
|
||||
}
|
||||
}
|
||||
if (!interBytes) {
|
||||
interBytes = new timeInterval(200, interBytesHandler);
|
||||
}
|
||||
interBytes.start();
|
||||
}
|
||||
private function interBytesHandler(): void {
|
||||
|
||||
//判断是否需要加载下一项
|
||||
var loaded: Number = nsArr[loadNum].getBytesLoaded();
|
||||
var loadTotal: Number = nsArr[loadNum].getBytesTotal();
|
||||
if (loaded >= loadTotal) {
|
||||
loadedArr[loadNum] = 2; //说明该段已加载
|
||||
if ((loadNum - playNum) < loadNext && loadNum < (nsArr.length - 1)) {
|
||||
loadNum++;
|
||||
if (loadedArr[loadNum] == 0) {
|
||||
nsArr[loadNum].load();
|
||||
loadedArr[loadNum] = 1; //说明该段正在加载
|
||||
}
|
||||
}
|
||||
else {
|
||||
interBytes.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
//提供给外部调用使用
|
||||
public function getTime(): Number {
|
||||
//trace(nsArr[playNum].getTime());
|
||||
//trace(nsArr[playNum].getTime(),script.arrSum(timeArr, playNum));
|
||||
//trace("当前播放:",playNum);
|
||||
var temp:Number=nsArr[playNum].getTime() + script.arrSum(timeArr, playNum);
|
||||
//trace(temp,"==");
|
||||
if(temp<timeTotal){
|
||||
return temp;
|
||||
}
|
||||
else{
|
||||
return timeTotal;
|
||||
}
|
||||
}
|
||||
public function getBytesLoaded(): Number {
|
||||
var temp:Number=nsArr[loadNum].getBytesLoaded() + script.arrSum(bytesArr, loadNum);
|
||||
if(temp>bytesMax){
|
||||
bytesMax=temp;
|
||||
}
|
||||
return bytesMax;
|
||||
}
|
||||
public function getDuration(): Number {
|
||||
return timeTotal;
|
||||
}
|
||||
public function getBytesTotal(): Number {
|
||||
return bytesTotal;
|
||||
}
|
||||
public function getBufferTime(): Number {
|
||||
return nsArr[playNum].getBufferTime();
|
||||
}
|
||||
public function getBufferLength(): Number {
|
||||
return nsArr[playNum].getBufferLength();
|
||||
}
|
||||
public function videoPlay(): void {
|
||||
nsArr[playNum].videoPlay();
|
||||
}
|
||||
public function videoPause(): void {
|
||||
nsArr[playNum].videoPause();
|
||||
}
|
||||
public function videoSeek(time: Number = 0): void {
|
||||
//nsArr[playNum].videoSeek();
|
||||
//计算该时间属于第几段
|
||||
|
||||
var position: int = 0; //属于第几段
|
||||
var t: int = 0;
|
||||
for (var i: int = 0; i < timeArr.length; i++) {
|
||||
t += timeArr[i];
|
||||
if (t > time) {
|
||||
position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var tempTime: int = time - script.arrSum(timeArr, position);
|
||||
//trace("客户",time,script.arrSum(timeArr, position-1),script.arrSum(timeArr, position),tempTime);
|
||||
if (position == playNum) { //在目前已播放的段落里播放
|
||||
nsArr[playNum].videoSeek(tempTime);
|
||||
}
|
||||
else { //不在目前已播放的段落里播放
|
||||
//trace("要跳转的===============",timeArr, position);
|
||||
nsArr[playNum].videoPause();
|
||||
newPlay(position, tempTime);
|
||||
}
|
||||
//trace("要跳转的",position,tempTime);
|
||||
}
|
||||
private function newPlay(position: int = 0, tempTime: int = 0): void { //播放指定段,指定时间
|
||||
//trace("跳转测试",streamArr[position] != null,playNum,position);
|
||||
playNum = position;
|
||||
if (streamArr[position] != null) { //如果要跳转的段落已加载
|
||||
//trace("执行监测时间01",new Date().getMilliseconds());
|
||||
streamSendOut(streamArr[position]);
|
||||
//trace("执行监测时间02",new Date().getMilliseconds());
|
||||
nsArr[position].videoSeek(tempTime);
|
||||
//trace("执行监测时间03",new Date().getMilliseconds());
|
||||
videoPlay();
|
||||
videoVolume(nowVolume);
|
||||
interBytes.start();
|
||||
|
||||
}
|
||||
else {
|
||||
deleteLoad();
|
||||
playSeek = tempTime;
|
||||
loadNum = position;
|
||||
interBytes.stop();
|
||||
nsArr[loadNum].load();
|
||||
loadedArr[loadNum] = 1; //说明该段正在加载
|
||||
}
|
||||
}
|
||||
private function deleteLoad(): void {
|
||||
//清除所有在加载又没有加载完的段数
|
||||
for (var i: int = 0; i < loadedArr.length; i++) {
|
||||
if (loadedArr[i] == 1 || (i<playNum && C.CONFIG["config"]["smartRemove"])) {
|
||||
nsArr[i].clear();
|
||||
nsArr[i]=null;
|
||||
var stream: httpstream = new httpstream();
|
||||
stream.videoUrl = des.getString(videoUrl[i]["file"]);
|
||||
stream.netStatus = NetStatus;
|
||||
stream.streamSendOut = StreamSendOut;
|
||||
stream.error = error;
|
||||
stream.NUM = i;
|
||||
nsArr[i]=stream;
|
||||
streamArr[i]=null;
|
||||
loadedArr[i]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public function videoVolume(val: Number = 0): void { //修改音量
|
||||
nowVolume = val;
|
||||
nsArr[playNum].videoVolume(val);
|
||||
}
|
||||
public function clear(): void {
|
||||
isClear = true; //设置清除
|
||||
for (var i = 0; i < nsArr.length; i++) {
|
||||
nsArr[i].clear();
|
||||
}
|
||||
if(getMeta){
|
||||
getMeta.clear();
|
||||
getMeta=null;
|
||||
}
|
||||
}
|
||||
public function errorNow(string:String=""):void{
|
||||
clear();
|
||||
error(string);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
package ckaction.player {
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import ckaction.C.C;
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.events.AsyncErrorEvent;
|
||||
import ckaction.act.script;
|
||||
import flash.media.SoundTransform;
|
||||
import flash.events.ErrorEvent;
|
||||
import ckaction.act.timeInterval;
|
||||
import ckaction.act.timeOut;
|
||||
|
||||
public class httpstream {
|
||||
public var videoUrl: String = "";
|
||||
public var netStatus: Function = null,
|
||||
streamSendOut: Function = null,
|
||||
error: Function = null; //发送流状态的函数,发送流的函数,统一用来报错的函数
|
||||
public var NUM: int = -1; //发送区别编号
|
||||
public var usehardwareeecoder:Boolean=false;
|
||||
private var nc: NetConnection = null;
|
||||
private var ns: NetStream = null;
|
||||
private var videoMeta: Object = null;
|
||||
private var playUrl: String = ""; //实际要播放的视频地址
|
||||
private var startTime: Number = 0,
|
||||
startBytes: Number = 0; //用来修正播放时间
|
||||
private var startTimeNum: int = 0,startLoadNum:int=0; //用来做3次计数,用来确认是否需要修正时间
|
||||
private var isClear: Boolean = false; //默认不清除
|
||||
private var frist: Boolean = true;
|
||||
private var DRAG: String = "";
|
||||
private var duration: Number = 0,
|
||||
bytesTotal: Number = 0;
|
||||
private var stopTimer: timeInterval = null; //用来在提前结束的情况下最终发送stop的定时器
|
||||
private var sendStop = false;
|
||||
private var timeCorrect: Boolean = false;
|
||||
public function httpstream() {
|
||||
DRAG = C.CONFIG["flashvars"]["drag"];
|
||||
timeCorrect = C.CONFIG["config"]["timeCorrect"];
|
||||
//trace("DRAG", DRAG);
|
||||
}
|
||||
public function load(): void {
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
nc = new NetConnection();
|
||||
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
|
||||
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
|
||||
nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netSteameErrorHandler);
|
||||
nc.connect(null);
|
||||
}
|
||||
private function netStatusHandler(event: NetStatusEvent): void {
|
||||
//trace("this:", event.info.code);
|
||||
|
||||
if (!timeCorrect) {
|
||||
if (NUM > -1) {
|
||||
netStatus(event.info.code, NUM);
|
||||
} else {
|
||||
netStatus(event.info.code);
|
||||
}
|
||||
} else {
|
||||
if (event.info.code != "NetStream.Play.Stop") {
|
||||
if (NUM > -1) {
|
||||
netStatus(event.info.code, NUM);
|
||||
} else {
|
||||
netStatus(event.info.code);
|
||||
}
|
||||
} else {
|
||||
//trace("=======",getTime() , duration - C.CONFIG["config"]["bufferTime"] * 0.001,duration,C.CONFIG["config"]["bufferTime"] * 0.001);
|
||||
if (getTime() >= duration - C.CONFIG["config"]["bufferTime"] * 0.01) {
|
||||
if (NUM > -1) {
|
||||
netStatus(event.info.code, NUM);
|
||||
} else {
|
||||
netStatus(event.info.code);
|
||||
}
|
||||
sendStop = true;
|
||||
} else {
|
||||
videoPlay();
|
||||
if (!stopTimer) {
|
||||
stopTimer = new timeInterval(C.CONFIG["config"]["bufferTime"] - 1, stopTimerHandler);
|
||||
}
|
||||
stopTimer.start();
|
||||
//trace("延迟秒数",(duration - getTime()));
|
||||
new timeOut((duration - getTime()) * 1000, function () {
|
||||
if (!sendStop) {
|
||||
//trace("确保发送")
|
||||
sendStop = true;
|
||||
if (stopTimer) {
|
||||
stopTimer.close();
|
||||
stopTimer = null;
|
||||
}
|
||||
if (NUM > -1) {
|
||||
netStatus("NetStream.Play.Stop", NUM);
|
||||
} else {
|
||||
netStatus("NetStream.Play.Stop");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (event.info.code) {
|
||||
case "NetConnection.Connect.Success":
|
||||
connectStream();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//trace(event.info.code);
|
||||
|
||||
}
|
||||
private function stopTimerHandler(): void {
|
||||
if (getTime() >= duration) {
|
||||
//trace("发送成功");
|
||||
if (NUM > -1) {
|
||||
netStatus("NetStream.Play.Stop", NUM);
|
||||
} else {
|
||||
netStatus("NetStream.Play.Stop");
|
||||
}
|
||||
sendStop = true;
|
||||
stopTimer.close();
|
||||
stopTimer = null;
|
||||
}
|
||||
//trace("检查发送");
|
||||
}
|
||||
private function securityErrorHandler(event: SecurityErrorEvent): void {}
|
||||
private function netSteameErrorHandler(event: AsyncErrorEvent): void {}
|
||||
private function connectStream(): void {
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
if (!playUrl) {
|
||||
playUrl = videoUrl;
|
||||
}
|
||||
var customClient = new Object();
|
||||
customClient.onMetaData = metaDataHandler;
|
||||
ns = new NetStream(nc);
|
||||
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
|
||||
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netSteameErrorHandler);
|
||||
ns.useHardwareDecoder=usehardwareeecoder;
|
||||
ns.client = customClient;
|
||||
ns.play(playUrl);
|
||||
}
|
||||
private function metaDataHandler(info: Object): void {
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
var metaDataObj: Object = {};
|
||||
if (!info.hasOwnProperty("duration")) {
|
||||
info["duration"] = 0;
|
||||
}
|
||||
if (frist) {
|
||||
info = script.getHttpKey(info);
|
||||
info["bytesTotal"] = ns.bytesTotal;
|
||||
videoMeta = info;
|
||||
if (!info.hasOwnProperty("keytime")) {
|
||||
DRAG = "";
|
||||
}
|
||||
metaDataObj = {
|
||||
type: "[object NetStream]",
|
||||
metaData: info
|
||||
};
|
||||
|
||||
}
|
||||
metaDataObj["netStream"] = ns;
|
||||
if (bytesTotal == 0 && ns.bytesTotal > 0) {
|
||||
bytesTotal = ns.bytesTotal;
|
||||
}
|
||||
if (duration == 0 && info["duration"] > 0) {
|
||||
duration = info["duration"];
|
||||
}
|
||||
frist = false;
|
||||
if (!info.hasOwnProperty("width")) {
|
||||
clear();
|
||||
error("There is no width for video metadata");
|
||||
return;
|
||||
}
|
||||
if (!info.hasOwnProperty("height")) {
|
||||
clear();
|
||||
error("There is no height for video metadata");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
if (NUM > -1) {
|
||||
//trace("运行了load",NUM,metaDataObj);
|
||||
streamSendOut(metaDataObj, NUM);
|
||||
//trace("运行了load==", NUM);
|
||||
} else {
|
||||
streamSendOut(metaDataObj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function newPlayUrl(time: Number = 0): void {
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
//trace(videoMeta["keytime"]);
|
||||
var keytime: Array = videoMeta["keytime"];
|
||||
//trace(keytime.length);
|
||||
var keyframes: Array = videoMeta["keyframes"];
|
||||
var index: int = 0;
|
||||
var start: String = "";
|
||||
for (var i: int = 0; i < keytime.length; i++) {
|
||||
if (time < keytime[i]) {
|
||||
index = i > 0 ? i - 1 : i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (time > keytime[keytime.length - 1]) {
|
||||
index = keytime.length - 1;
|
||||
}
|
||||
//trace("++++++++++++++++++++++++++++++++++",time);
|
||||
//trace(index);
|
||||
//trace(keytime[index]);
|
||||
//trace("++++++++++++++++++++++++++==========++++++++");
|
||||
//script.log(time);
|
||||
//script.log(keytime);
|
||||
//mp4文件按关键时间点
|
||||
var drag: String = script.replace(DRAG, ["time_", "frames_"], ["", ""]);
|
||||
if (script.getFileExt(videoUrl) == ".mp4") {
|
||||
start = drag + "=" + keytime[index];
|
||||
} else {
|
||||
start = drag + "=" + keyframes[index];
|
||||
}
|
||||
if (DRAG.indexOf("time_") > -1) {
|
||||
start = drag + "=" + keytime[index];
|
||||
}
|
||||
if (DRAG.indexOf("frames_") > -1) {
|
||||
start = drag + "=" + keyframes[index];
|
||||
}
|
||||
startTime = keytime[index];
|
||||
startBytes = keyframes[index];
|
||||
if (videoUrl.indexOf("?") > -1) {
|
||||
playUrl = videoUrl.replace("?", "?" + start + "&"); //videoUrl + "&" + start;
|
||||
} else {
|
||||
playUrl = videoUrl + "?" + start;
|
||||
}
|
||||
//trace(keytime[index]);
|
||||
//trace(playUrl);
|
||||
|
||||
startTimeNum = 0; //重置计数
|
||||
startLoadNum=0;
|
||||
if (ns) {
|
||||
ns.close();
|
||||
ns.play(playUrl);
|
||||
}
|
||||
|
||||
}
|
||||
private function getNewTime(time: Number): Number { //根据当前加载量计算跳转时间
|
||||
//var bytesLoaded: Number = ns.bytesLoaded;
|
||||
//var bytesTotal: Number = ns.bytesTotal;
|
||||
var limitTime: Number = ns.bytesLoaded * duration / bytesTotal;
|
||||
if (time > limitTime) {
|
||||
return limitTime;
|
||||
}
|
||||
return time;
|
||||
}
|
||||
//提供给外部调用使用
|
||||
public function getTime(): Number {
|
||||
if (ns) {
|
||||
var time: Number = ns.time;
|
||||
//trace("time:",time,startTime,startTimeNum);
|
||||
if (time < startTime && startTimeNum<300 && time>0) {
|
||||
startTimeNum++;
|
||||
}
|
||||
if (time < startTime || startTimeNum > 6) {
|
||||
time += startTime;
|
||||
}
|
||||
return time;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
public function getBytesLoaded(): Number {
|
||||
if (ns) {
|
||||
var bytesLoaded: Number = ns.bytesLoaded;
|
||||
//trace("startBytes",startBytes,bytesLoaded);
|
||||
if (bytesLoaded < startBytes && startLoadNum<300 && bytesLoaded>0) {
|
||||
startLoadNum ++;
|
||||
}
|
||||
if (bytesLoaded < startBytes || startLoadNum > 6) {
|
||||
bytesLoaded += startBytes;
|
||||
}
|
||||
return bytesLoaded;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public function getDuration(): Number {
|
||||
return duration;
|
||||
}
|
||||
public function getBytesTotal(): Number {
|
||||
//trace(NUM,"总字节:",bytesTotal);
|
||||
return bytesTotal;
|
||||
}
|
||||
public function getBufferTime(): Number {
|
||||
if (ns && getTime() < getDuration() - C.CONFIG["config"]["bufferTime"] * 0.001) {
|
||||
return ns.bufferTime;
|
||||
}
|
||||
return (C.CONFIG["config"]["bufferTime"] * 0.001) * 2;
|
||||
}
|
||||
public function getBufferLength(): Number {
|
||||
if (ns) {
|
||||
return ns.bufferLength;
|
||||
}
|
||||
return 0.2;
|
||||
}
|
||||
public function videoPlay(): void {
|
||||
if (ns) {
|
||||
ns.resume();
|
||||
}
|
||||
}
|
||||
public function videoPause(): void {
|
||||
if (ns) {
|
||||
ns.pause();
|
||||
}
|
||||
}
|
||||
public function videoSeek(time: Number = 0): void {
|
||||
//trace("要跳转的时间:",time);
|
||||
if (ns) {
|
||||
if (DRAG == "") {
|
||||
ns.seek(getNewTime(time));
|
||||
} else {
|
||||
if (playUrl.indexOf(script.replace(DRAG, ["time_", "frames_"], ["", ""]) + "=") > -1) {
|
||||
newPlayUrl(time);
|
||||
} else {
|
||||
if (time <= getNewTime(time)) {
|
||||
ns.seek(time);
|
||||
} else {
|
||||
newPlayUrl(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function videoVolume(val: Number = 0): void { //修改音量
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
var v: SoundTransform = ns.soundTransform;
|
||||
v.volume = val;
|
||||
if (ns) {
|
||||
ns.soundTransform = v;
|
||||
}
|
||||
}
|
||||
|
||||
public function clear(): void {
|
||||
isClear = true; //设置清除
|
||||
if (nc != null) {
|
||||
nc.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
|
||||
nc.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
|
||||
nc = null;
|
||||
}
|
||||
if (ns != null) {
|
||||
ns.dispose();
|
||||
ns.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
|
||||
ns.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, netSteameErrorHandler);
|
||||
ns = null;
|
||||
}
|
||||
}
|
||||
//提供给外部调用结束
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,266 @@
|
||||
package ckaction.player {
|
||||
import flash.net.NetConnection;
|
||||
import flash.net.NetStream;
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.events.AsyncErrorEvent;
|
||||
import flash.media.SoundTransform;
|
||||
import ckaction.act.TEA;
|
||||
import ckaction.act.timeOut;
|
||||
import flash.net.ObjectEncoding;
|
||||
import flash.events.ErrorEvent;
|
||||
|
||||
public class rtmpstream {
|
||||
public var videoUrl: String = "";
|
||||
|
||||
public var netStatus: Function = null,
|
||||
streamSendOut: Function = null,
|
||||
error: Function = null; //发送流状态的函数,发送流的函数,统一用来报错的函数
|
||||
public var secureToken: String = ""; //secureToken验证串
|
||||
public var fcsubscribe: Boolean = false; //是否采用FC
|
||||
public var username: String = "",
|
||||
password: String = "";
|
||||
public var userid:int=0;
|
||||
public var videoWH:Object={
|
||||
defaultWidth:4,
|
||||
defaultHeight:3
|
||||
};
|
||||
public var usehardwareeecoder:Boolean=false;
|
||||
public var bufferTime:int=0;
|
||||
private var nc: NetConnection = null;
|
||||
private var ns: NetStream = null;
|
||||
private var rtmp: String = "",
|
||||
live: String = "";
|
||||
private var isClear: Boolean = false; //默认不清除
|
||||
private var ncClose: Boolean = false;
|
||||
private var first: Boolean = true;
|
||||
private var duration: Number = 0;
|
||||
private var isInfo:Boolean=false;
|
||||
|
||||
public function rtmpstream() {
|
||||
// constructor code
|
||||
}
|
||||
|
||||
public function load(): void {
|
||||
trace("新建了一个rtmp_load");
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
//分析地址
|
||||
var arr: Array = videoUrl.split("|");
|
||||
if (arr.length == 2) {
|
||||
rtmp = arr[0];
|
||||
live = arr[1];
|
||||
} else {
|
||||
videoUrl.replace("mp4:mp4","mp4");
|
||||
arr = videoUrl.split("mp4:");
|
||||
if (arr.length >= 2) {
|
||||
rtmp = arr[0];
|
||||
if(rtmp.lastIndexOf("/")==rtmp.length-1){
|
||||
rtmp=rtmp.substr(0,rtmp.lastIndexOf("/"));
|
||||
}
|
||||
for(var i:int=1;i<arr.length;i++){
|
||||
if(i==1){
|
||||
live+="mp4:";
|
||||
}
|
||||
live += arr[i];
|
||||
}
|
||||
} else {
|
||||
var x:int = videoUrl.lastIndexOf("/");
|
||||
arr = [];
|
||||
if (x > 0) {
|
||||
arr.push(videoUrl.substr(0, x), videoUrl.substr(x + 1));
|
||||
}
|
||||
if (arr.length == 2) {
|
||||
rtmp = arr[0];
|
||||
live = arr[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
trace("rtmp:"+rtmp);
|
||||
trace("live:"+live);
|
||||
//return;
|
||||
nc = new NetConnection();
|
||||
nc.client=this;
|
||||
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
|
||||
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
|
||||
nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
|
||||
nc.objectEncoding=ObjectEncoding.AMF0;
|
||||
//nc.connect(rtmp);
|
||||
if (userid > 0) {
|
||||
nc.connect(rtmp, userid);
|
||||
}
|
||||
else if (username != "" && password == "") {
|
||||
nc.connect(rtmp + '?' + username.replace("|", "&"));
|
||||
}
|
||||
else if (username != "" && password != "") {
|
||||
nc.connect(rtmp, username, password);
|
||||
}
|
||||
else {
|
||||
nc.connect(rtmp);
|
||||
}
|
||||
trace(rtmp);
|
||||
}
|
||||
private function netStatusHandler(event: NetStatusEvent): void {
|
||||
trace(event.info.code);
|
||||
//return;
|
||||
netStatus(event.info.code);
|
||||
switch (event.info.code) {
|
||||
case "NetConnection.Connect.Success":
|
||||
if (secureToken && event.info.secureToken != undefined) {
|
||||
nc.call("secureTokenResponse", null, TEA.decrypt(event.info.secureToken, secureToken));
|
||||
}
|
||||
if (fcsubscribe) {
|
||||
nc.call("FCSubscribe", null, live);
|
||||
}
|
||||
connectStream();
|
||||
break;
|
||||
case "NetStream.Play.Start":
|
||||
new timeOut(500,function(){
|
||||
trace("发送没有");
|
||||
if(!isInfo){
|
||||
metaDataHandler({
|
||||
width:videoWH["defaultWidth"],
|
||||
height:videoWH["defaultHeight"],
|
||||
duration:0
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "NetConnection.Connect.Closed": //针对rtmp流暂停后被关闭的操作
|
||||
ncClose = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
private function securityErrorHandler(event: SecurityErrorEvent): void {}
|
||||
private function netSteameErrorHandler(event: AsyncErrorEvent): void {}
|
||||
private function asyncErrorHandler(event: AsyncErrorEvent): void {}
|
||||
private function connectStream(): void {
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
var customClient = new Object();
|
||||
ns = new NetStream(nc);
|
||||
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
|
||||
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netSteameErrorHandler);
|
||||
customClient.onMetaData = metaDataHandler;
|
||||
ns.client = customClient;
|
||||
//useHardwareDecoder
|
||||
ns.useHardwareDecoder=usehardwareeecoder;
|
||||
trace("缓冲",bufferTime*0.001);
|
||||
//ns.bufferTime=bufferTime*0.001;
|
||||
ns.play(live);
|
||||
trace("live",live);
|
||||
//ns.pause();
|
||||
}
|
||||
private function metaDataHandler(info: Object): void {
|
||||
if(isInfo){
|
||||
return;
|
||||
}
|
||||
isInfo=true;
|
||||
//ns.pause();
|
||||
if (first) {
|
||||
first = false;
|
||||
info["bytesTotal"] = 0;
|
||||
var metaDataObj: Object = {};
|
||||
//info["bytesTotal"] = ns.bytesTotal;
|
||||
metaDataObj = {
|
||||
type: "[object NetStream]",
|
||||
metaData: info
|
||||
};
|
||||
metaDataObj["netStream"] = ns;
|
||||
if(info.hasOwnProperty("duration")){
|
||||
duration = info["duration"];
|
||||
}
|
||||
else{
|
||||
duration = 0;
|
||||
}
|
||||
|
||||
if (isClear) { //如果已被清除,则不进行下面的动作
|
||||
return;
|
||||
}
|
||||
trace("发送了一次");
|
||||
streamSendOut(metaDataObj);
|
||||
|
||||
}
|
||||
}
|
||||
//供外部播放时调用
|
||||
public function getNs():NetStream{
|
||||
return ns;
|
||||
}
|
||||
//提供给外部调用使用
|
||||
public function getTime(): Number {
|
||||
if (ns) {
|
||||
return ns.time;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public function getDuration(): Number {
|
||||
return duration;
|
||||
}
|
||||
public function getBytesLoaded(): Number {
|
||||
return 0;
|
||||
}
|
||||
public function getBytesTotal(): Number {
|
||||
return 0;
|
||||
}
|
||||
public function getBufferTime(): Number {
|
||||
if (ns) {
|
||||
return ns.bufferTime;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public function getBufferLength(): Number {
|
||||
if (ns) {
|
||||
return ns.bufferLength;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public function videoPlay(): void {
|
||||
trace("================================================================调用了videoPlay()");
|
||||
if (ns) {
|
||||
trace("================================================================调用了ns.resume()");
|
||||
ns.resume();
|
||||
}
|
||||
}
|
||||
public function videoPause(): void {
|
||||
if (ns) {
|
||||
ns.pause();
|
||||
}
|
||||
}
|
||||
//提供给外部调用结束
|
||||
public function clear(): void {
|
||||
isClear = true; //设置清除
|
||||
if (ns) {
|
||||
if (!ncClose) {
|
||||
ns.dispose();
|
||||
}
|
||||
ns.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
|
||||
ns.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, netSteameErrorHandler);
|
||||
ns = null;
|
||||
}
|
||||
if (nc) {
|
||||
nc.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
|
||||
nc.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
|
||||
nc.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
|
||||
nc = null;
|
||||
}
|
||||
}
|
||||
public function videoSeek(time: Number = 0): void {
|
||||
if (ns) {
|
||||
ns.seek(time);
|
||||
}
|
||||
}
|
||||
public function videoVolume(val: Number = 0): void { //修改音量
|
||||
var v: SoundTransform = ns.soundTransform;
|
||||
v.volume = val;
|
||||
if (ns) {
|
||||
ns.soundTransform = v;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user