0 Replies Latest reply on Dec 8, 2007 9:47 AM by tallakh

    Not able to load movie

    tallakh
      Hi,

      I'm trying to develope a flex based h.264 movie player, but I have ran into
      some problems. I have followed the online tutorial
      http://www.adobe.com/devnet/flashplayer/articles/hd_video_flash_player.html
      but the movie does not start and there is an error returned called
      "NetStream.Play.FileStructureInvalid". I quite sure that the movie files
      that I have tested are valid h.264 and they are playable in movie players,
      so I am thinking that it is something else. In fact, when I use a non
      existing file name, the same error is returned.

      BTW, I'm compiling using -use-network=false as it is using a local
      filesystem

      Any help is much appreciated as this is my fist project using flex and as3!

      Thanks,
      Tallak

      mxml:
      *****
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute"
      verticalAlign="middle"
      horizontalAlign="center"
      backgroundColor="black"
      width="512"
      height="360"
      xmlns:video="video.*">
      <video:H264Video id="video_h264" filePath="test.mov"/>
      </mx:Application>
      *****

      video/H264Video.as
      *****
      package video
      {
      import mx.core.UIComponent;
      import flash.events.NetStatusEvent;
      import flash.net.NetConnection;
      import flash.net.NetStream;
      import mx.controls.Alert
      import flash.media.Video;

      public class H264Video extends UIComponent {
      private var _video:Video;
      private var _connection_nc:NetConnection;
      private var _stream_ns:NetStream;
      private var _client:Object;
      private var _filePath:String;

      public function H264Video()
      {
      super();
      init();
      }

      public function init():void
      {
      _video = new Video();
      _connection_nc = new NetConnection();
      _connection_nc.connect(null);

      _stream_ns = new NetStream(_connection_nc);
      _client = new Object();
      _stream_ns.client = _client;
      _stream_ns.addEventListener(NetStatusEvent.NET_STATUS, onStatus);

      _video.attachNetStream(_stream_ns);

      this.addChild(_video);
      if(_filePath)
      {
      _stream_ns.play(_filePath);
      }
      }

      private function onStatus(p_evt:NetStatusEvent):void
      {
      if(p_evt.info.code == "NetStream.Play.FileStructureInvalid")
      {
      Alert.show("The MP4's file structure is invalid.", "Status");
      }
      else if(p_evt.info.code == "NetStream.Play.NoSupportedTrackFound")
      {
      Alert.show("The MP4 doesn't contain any supported tracks",
      "Status");
      }
      else if(p_evt.info.level == "error")
      {
      Alert.show("There was some sort of error with the NetStream",
      "Error");
      }
      }

      [Bindable]
      public function get filePath():String
      {
      return _filePath;
      }

      public function set filePath(p_path:String):void

      {
      _filePath = p_path;
      _stream_ns.play(_filePath);
      }
      }
      }
      *****