播放视频时遇到问题。随机播放视频,视频正在播放,因为播放头移动并发出声音。

这很奇怪,因为如果我按暂停然后播放视频就会出现,如果我将其设为全屏,则会出现。

private var videoURL:String = "filename.f4v";
private function setupConnection():void
{
    connection = new NetConnection();
    connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
    connection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onErrorConnect);
    connection.connect("rtmp://url to my streaming server");       
}

private function netStatusHandler(event:NetStatusEvent):void
{
    trace("event.info.code "+event.info.code);
    switch (event.info.code) {
        case "NetConnection.Connect.Success":
            connectStream();
            break;
         case "NetStream.Play.Start":
            onPlayVideoHandler();
            break;
        case "NetStream.Play.StreamNotFound":
            trace("Stream not found: " + videoURL);
            break;
        default :
    }         
}      

private function onErrorConnect(event:AsyncErrorEvent):void
{
    trace("onErrorConnect: " + event);
}         

private function securityErrorHandler(event:SecurityErrorEvent):void
{
    trace("securityErrorHandler: " + event);
}

private function connectStream():void
{
    stream = new NetStream(connection);
    stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    stream.bufferTime   = 10;           

    var client:Object   = new Object();
    client.onMetaData   = onMetaData;
    stream.client       = client;           

    video           = new Video(200, 200);
    video.name      = "video";
    video.addEventListener(Event.ADDED_TO_STAGE, videoAddedToStage)
    video.attachNetStream(stream);
    video.smoothing     = true;
    video.x         = 0;
    video.y         = 0;
    mainHolder.addChild(video); 

    stream.play(videoURL, 0, 100, true);        
    stream.seek(0);
}

private function onPlayVideoHandler():void
{
        // add Controls
}

好的我已经发现它没有显示的原因是因为视频有时的宽度和高度为0像素。有谁知道它为什么会返回这些值?这是rtmp流媒体视频的本质吗?

有帮助吗?

解决方案

在继续之前,我必须先听宽度和高度大于零。我从未发现为什么,但这是如何解决它。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top