gpt4 book ai didi

flash - 如何将 netstream.appendBytes() 用于 http 动态流?

转载 作者:行者123 更新时间:2023-12-01 14:34:22 31 4
gpt4 key购买 nike

我正在尝试了解如何在 Flash 10.1 中使用 http 动态流式传输,但我无法使用基本功能。对视频文件使用 appendbytes 的语法是什么?

package com.player {

import flash.display.Stage;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.display.Sprite;
import flash.net.URLRequest;
import flash.net.URLStream;
import flash.events.Event;
import flash.utils.ByteArray;

public class Player extends Sprite {

const vurl = "file://E:/clip.flv"

private var nc:NetConnection;
private var ns:NetStream;
private var vo:Video;



private var urlstream:URLStream;

public function Player() {

nc = new NetConnection();
nc.connect(null);

ns = new NetStream(nc);
ns.client = new StreamClient();

vo = new Video();
vo.attachNetStream(ns);

addChild(vo);

ns.play(vurl);

var urlrequest:URLRequest = new URLRequest(vurl)
urlstream = new URLStream();

urlstream.addEventListener(Event.COMPLETE, completeHandler);

urlstream.load(urlrequest);



}

private function completeHandler(event:Event):void {
trace("completeHandler: " + event);

var bytes:ByteArray = new ByteArray();

urlstream.readBytes(bytes);

ns.appendBytes(bytes);
}


}

运行这个给我错误:

TypeError: Error #2004: One of the parameters is invalid. at flash.net::NetStream/appendBytes() at ...

最佳答案

我找到了解决问题的办法。你必须从 ns.play(null) 而不是 ns.play('url to download'); 开始;

关于flash - 如何将 netstream.appendBytes() 用于 http 动态流?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3220730/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com