Topic: Trying to stream FLV video to Chumby using swfmill and mtasc

I'm attempting to stream FLV videos to my Chumby and have been having some difficulties.  I can get the sound to work, but I can't get the video to display.  I can't seem to figure out how to get the video stream attached to the stage.  All the examples I've been able to find use a magical "myvideo", but never describe how it gets created and attached.

Does anyone know how to connect the NetStream video object to the _root stage?

Here is my MTASC ActionScript file (Main.as):

class MyThumb extends MovieClip
{
   var vid:Video;
   var myVideo:MovieClip;
   var nc:NetConnection;
   var ns:NetStream;
   var state = 0;

   function onLoad()
   {
      myVideo._root.attachMovie("myVideo1","myVideo",_root.getNextHighestDepth());
      nc = new NetConnection();
      nc.connect(null);
      ns = new NetStream(nc);
      myVideo.vid.attachVideo(ns);
      ns.play("http://192.168.1.200/video/test.flv");
      ns.pause();
   }

   function onMouseDown()
   {
      if (state == 0)
      {
        state = 1;
        _root.createTextField("info2",0, 0,0, 100,30);
        _root.info2.setNewTextFormat( new TextFormat("Arial") );
        _root.info2.textColor=0xff0000;
        _root.info2.text = "moo_moo.flv";
        ns.play("http://192.168.1.200/video/moo_moo.flv");
      } else {
        state = 0
        _root.createTextField("info",0, 0,0, 100,30);
        _root.info.setNewTextFormat( new TextFormat("Arial") );
        _root.info.textColor=0xff0000;
        _root.info.text = "test.flv";
        ns.play("http://192.168.1.200/video/test.flv");
      }

   }

}

Here is my swfmill XML file (video.xml):

<?xml version="1.0" encoding="utf-8" ?>
<movie version="8" width="320" height="240" framerate="12">
   <frame>
      <clip id="classes.swf" import="classes.swf"/>
      <clip id="moo_moo.jpg" import="moo_moo.jpg"/>

      <library>

         <clip id="Thumb" class="MyThumb">
            <frame>
               <place id="moo_moo.jpg"/>
            </frame>
         </clip>

         <clip id="myVideo">
            <frame>
               <place id="VideoSurface" name="vid"/>
               <video id="VideoSurface"/>
            </frame>
         </clip>

      </library>

      <place id="Thumb"/>

   </frame>
</movie>

I compile them with the following commands:

mtasc Main.as VideoDisplay.as -version 8 -wimp -swf classes.swf -header 320:240:12
swfmill simple video.xml video.swf

Then I copy it over to the Chumby's USB drive.

Thanks,
-Ron

Re: Trying to stream FLV video to Chumby using swfmill and mtasc

Yeah, there seems to be some kind of problem doing this on the chumby. It could be a problem with the way mtasc/swfmill work or the version of flashlite works or even something entirely different. I could never get this to work. If I do a similar thing using "official" Flash tools, that works fine!

Re: Trying to stream FLV video to Chumby using swfmill and mtasc

In Actionscript 2 you have to create a Video object in the Library or on the Stage to use. You can't create it using Actionscript alone.

You commonly create these Video objects in the Flash IDE. SWFMill users may have a workaround for this but I don't know of one.

Re: Trying to stream FLV video to Chumby using swfmill and mtasc

I finally got it to work!  Here is my code, just in case someone else is ever looking for a way to stream FLV video to a flash widget using swfmill and mtasc.

video.as:

class myVideo extends MovieClip
{
   var nc:NetConnection;
   var ns:NetStream;

   function onLoad()
   {
      nc = new NetConnection();
      nc.connect(null);
      ns = new NetStream(nc);
      //_root["VideoDisplay"]["vid"].attachVideo(ns);
      _root.VideoDisplay.vid.attachVideo(ns);
      ns.play("FLV URL");
   }

   function onMouseDown()
   {
      ns.pause();
   }
}

video.xml:

<?xml version="1.0" encoding="utf-8" ?>
<movie version="8" width="320" height="240" framerate="12">
   <background color="#ff00ff"/>
   <frame>
      <clip id="classes.swf" import="classes.swf"/>
      <video id="vid" depth="3" width="320" height="240" />

      <library>
        <clip id="VideoDisplay1" class="myVideo">
          <frame>
            <place id="vid" depth="4" name="vid" />
          </frame>
        </clip>
      </library>

      <place id="VideoDisplay1" name="VideoDisplay" depth="0" />
   </frame>
</movie>

to compile:

mtasc video.as -wimp -version 8 -swf classes.swf -header 320:240:12
swfmill simple video.xml video.swf

I'm still a little confused on the difference between id and name in the swfmill XML file.  Inside the library-clip-frame, the id and name both need to match what is in the ActionScript code (the vid in _root.VideoDisplay.vid).  However, in the <place> near the bottom of the XML file, the name must match what's in the ActionScript, but the id doesn't need to match (the VideoDisplay in _root.VideoDisplay.vid).  Anyway, this code works in Firefox, the virtual Chumby and on the Chumby itself; although it does seem a little choppy on the Chumby.

Re: Trying to stream FLV video to Chumby using swfmill and mtasc

thanks for the code!

any chances to get 25fps?

Re: Trying to stream FLV video to Chumby using swfmill and mtasc

infinite, what happens if you change the mtasc command line to have "320:240:24" at the end?  That should adjust the native frame rate of the movie to 24fps.