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();

  • 相关阅读:
    Codeforces 878A
    Codeforces 873B-Balanced Substring
    codeforces 868C
    51nod 1402 最大值(贪心)
    最小正子段和 贪心
    codeforces 819B
    Codeforces 785D
    Codeforces 864E
    863D
    UVA 1380 A Scheduling Problem
  • 原文地址:https://www.cnblogs.com/yanshuoistutu/p/2763440.html
Copyright © 2011-2022 走看看