zoukankan      html  css  js  c++  java
  • 视频加载

    (pauseBtn 、playBtn、stopBtn 和 togglePauseBtn为四个按钮)

    var nc:NetConnection = new NetConnection(); /*NetConnection 类在 Flash Player 和 Flash Media Server 应用程序之间或者 Flash Player 和运行 Flash Remoting 的应用程序服务器之间创建双向连接。NetConnection 对象如同客户端与服务器之间的管道。 可使用 NetStream 对象通过此管道发送流。*/ 
    nc.connect(null);

    var ns:NetStream = new NetStream(nc); /*NetStream类在 Flash Player 和 Flash Media Server 之间或者 Flash Player 和本地文件系统之间打开单向流连接。NetStream对象是 NetConnection 对象中的一个通道。 此通道可以使用 NetStreamm.publish() 发布流,也可以使用NetStream.play() 订阅发布的流并接收数据。 您可以发布或播放实时数据及先前录制的数据*/
    ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); /*如果异常是从本机异步代码中引发的(例如,可能从 LocalConnection、NetConnection、SharedObject 或 NetStream 引发),Flash ® Player 将调度 AsyncErrorEvent。 只有一种类型的异步错误事件:AsyncErrorEvent.ASYNC_ERROR。*/ 
    ns.play("video.flv");
    function asyncErrorHandler(event:AsyncErrorEvent):void
    {
    // ignore error
    }

    var vid:Video = new Video();
    vid.attachNetStream(ns);
    addChild(vid);

    pauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);
    playBtn.addEventListener(MouseEvent.CLICK, playHandler);
    stopBtn.addEventListener(MouseEvent.CLICK, stopHandler);
    togglePauseBtn.addEventListener(MouseEvent.CLICK, togglePauseHandler);

    function pauseHandler(event:MouseEvent):void
    {
    ns.pause();
    }
    function playHandler(event:MouseEvent):void
    {
    ns.resume();
    }
    function stopHandler(event:MouseEvent):void
    {
    // Pause the stream and move the playhead back to
    // the beginning of the stream.
    ns.pause();
    ns.seek(0);
    }
    function togglePauseHandler(event:MouseEvent):void
    {
    ns.togglePause();

  • 相关阅读:
    Python将文本生成二维码
    Python 发送邮件
    北京地铁月度消费总金额计算(Python版)
    将w3cplus网站中的文章页面提取并导出为pdf文档
    [开发笔记]-MarkDown语法
    linux多版本php安装+采坑指南
    浏览器跨域暴力解决
    php7使用xhprof测试php性能
    vscode使用xdebug断点调试php代码(无论win还是linux)
    ghostscript之pdf处理
  • 原文地址:https://www.cnblogs.com/yanshuoistutu/p/2763440.html
Copyright © 2011-2022 走看看