To transfer this to a SMIL file (handy if you are looking to support Dynamic Streaming in FMS) you would do this:
<head>
<meta base="rtmp://myserver.com/vod" />
</head>
<body>
<switch>
<video src="video_300.flv" system-bitrate="300000"/>
<video src="video_600.flv" system-bitrate="600000"/>
<video src="video_900.flv" system-bitrate="900000"/>
<video src="video_1300.flv" system-bitrate="1300000"/>
</switch>
</body>
</smil>
Looks plausible doesn't it? Shame then this DOES NOT WORK. Did you spot the error? Yeah, I'm such a noob, it's obvious isn't it?
If you want this work properly then you must OMIT THE FILE EXTENSION.
This works:
<head>
<meta base="rtmp://myserver.com/vod" />
</head>
<body>
<switch>
<video src="video_300" system-bitrate="300000"/>
<video src="video_600" system-bitrate="600000"/>
<video src="video_900" system-bitrate="900000"/>
<video src="video_1300" system-bitrate="1300000"/>
</switch>
</body>
</smil>
How about using a bunch of mp4s? You would think that you could do this:
Don't be silly. Of course that won't work, we know we must omit the file extension, right? Wrong. That will fail too. What you need is this:
You must add the file extension AND the mp4 prefix (apparently) if you want to use mp4s with SMIL. The FLVPlayback component is less fussy when it comes to direct references to a video, then it seems to play either rtmp://myserver.com/vod/video.flv or rtmp://myserver.com/vod/video just fine. I haven't tried the intricacies of referencing an mp4 directly. Clear as mustard, isn't it? :)
I can barely imagine how someone new to Flash may figure these things out - guess they could RTFM (yeah I should have I think) which I assume are correct and up to date. I'm sure some Adobe folks can explain why it behaves as it does and the technical reasons for it but that's missing the point - the component should be more intelligent and intuitive to use and it is isn't. I guess Strobe can't come soon enough and it won't repeat those mistakes.
And on this note I close another chapter of Flash frustrations and wish everyone a great weekend.


and the missing mp4: before the f4v, I just had that same problem when making my flash player accept js calls to play new videos I needed to kill re flv part but I overlooked maybe adobe should fix that not us
How do you use an SMIL file when you aren't using the FLVPlayback component?
I am just using straight AS3 to play back an FLV on my webserver (progressive download) and it works fine. The code goes something like this ...
var videoURL:String = "http://www.mysite.com/video.flv";
var netConnection:NetConnection = new NetConnection();
netConnection.connect(null);
var netStream:NetStream = new NetStream(netConnection);
var video:Video = new Video();
video.attachNetStream(netStream);
netStream.play(videoURL);
addChild(video);
However, once the file is uploaded to a streaming server (I'm using the streaming company Groovy Gecko) they tell me to link to an SMIL file, not directly to an FLV file. Then my code breaks. If I put the path the to SMIL in to a regular FLVPlayback component, then it works.
Any ideas?
Cheers,
Adrian
the FLVPlayback component does itts own parsing of the SMIL, so using the reference to it in your code won't work.
The upcoming OSFM (Strobe) framework will have some classes to do SMIL parsing and bandwidth switching and unless you can code such logic yourself you are better advised to use FLVPlayback for now.
Thanks for your speedy response.
That's really annoying. I've built a perfectly working bespoke video player with all the graphics in. And as soon as the FLV is hosted on an FMS server, it breaks. Arse!
If I view the SMIL file in Firefox I can see the XML. I've tried copying and pasting the 'base' and 'src' attributes out of the SMIL and hardcoding them in to my AS3 code but it still doesn't want to work. So that would imply that even if I parse the SMIL XML file at run time it wouldn't work either.
The thought of ditching what I have done and starting again by skinning the FLVPlayback component fills me with dread!
Frustratedly,
Adrian
If dynamic streaming is not what you need then SMIL has not got that much to offer tbh.
I've got it to work by loading in the SMIL file using URLLoader and URLRequest. Then when the COMPLETE event is triggered I can parse the XML and grab the 'base' and 'src' attributes and store then in variables.
I then set up the new NetConnection like so ...
netConnection = new NetConnection();
netConnection.addEventListener(NetStatusEvent.NET_STATUS, onNetConnection_NET_STATUS);
netConnection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onNetConnection_ASYNC_ERROR);
netConnection.connect(base);
The NET_STATUS handler looks like this ...
function onNetConnection_NET_STATUS(event:NetStatusEvent):void {
trace(event.info.code);
switch (event.info.code) {
case "NetConnection.Connect.Rejected":
trace("Rejected by server. Reason is "+event.info.description);
break;
case "NetConnection.Connect.Success":
connectedHandler();
break;
}
}
And then the 'connectedHandler' looks like this ...
function connectedHandler():void {
trace("connectedHandler()");
netStream = new NetStream(netConnection);
netStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStream_NET_STATUS);
netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onNetStream_ASYNC_ERROR);
var video:Video = new Video();
video.width = 512;
video.height = 288;
video.x = 0;
video.y = 30;
video.attachNetStream(netStream);
addChild(video);
netStream.play(src);
}
The part that I was missing was 'netConnection.connect(base)'
Thanks,
Adrian
I don't want to use SMIL (I'd rather just link directly to an FLV file). But the details that the streaming media (Groovy Gecko) have provided are a link to an SMIL file. So I don't have any choice.
Ta,
Adrian