FlashComGuru Home InfluxisCDNImediaseeUvault
                                                                                       Forum Index | Active Topics | Register
                                                                                                          List Overview | List Archives
                                                                                                                           About this site | Advertise
 

home

Adobe AIR (10)
Applications (39)
Books & Training (11)
Collaboration (18)
Components (10)
Events (79)
Flash Player (33)
Flex (38)
FMS (109)
General (123)
Hosting (5)
Jobs (16)
Off topic (36)
OSMF (3)
Press Releases (23)
Site Check (11)
Tools (53)
Videos & Players (72)

Follow me on Twitter

 
I'm not sure if I have or haven't blogged this once before, but a second time can't hurt anyway. I've just spent another half hour trying to get a simple SMIL file to work in conjunction with the FLVPlayback component. Normally this should be quite easy: you establish the rtmp address of the video you want to play, assign this as the source property of the FLVPlayback component and you're done. Like so:
mycomponent.source = "rtmp://myserver.com/vod/video.flv"

To transfer this to a SMIL file (handy if you are looking to support Dynamic Streaming in FMS) you would do this:

<smil>
<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:

<smil>
<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:
<video src="myvid.f4v" system-bitrate="150000"/>

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:
<video src="mp4:myvid.f4v" system-bitrate="150000"/>

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.

Comments
[Add Comment]
If the .flv extension is not documented, then it's likely my fault for overlooking it. This shouldn't be a problem with Strobe. For FLVPlayback, these values are pass-through, so the stream names listed in the SMIL file are as they would be passed to NetStream. This is why MP4 files need the prefix. FMS assumes the file type is FLV unless otherwise stated as MP4 or MP3 or ID3. The parser in FLVPlayback doesn't make assumptions based on the extension. Strobe may have that ability however.
# Posted By Brad | 6/12/09 6:51 PM
the only thing out of place is the. .flv extension
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
# Posted By ramón | 6/14/09 7:32 PM
Hi Stefan,

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
# Posted By Adrian Parr | 9/8/09 2:06 PM
hi 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.
# Posted By Stefan Richter | 9/8/09 2:28 PM
Hi Stefan,

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
# Posted By Adrian Parr | 9/8/09 2:44 PM
Why do you want to use SMIL? You'll be ok streaming from FMS and connecting to an FLV using your code, but in order to use SMIL you need to do a bit more.
If dynamic streaming is not what you need then SMIL has not got that much to offer tbh.
# Posted By Stefan Richter | 9/8/09 3:48 PM
Ok, I've has some success.

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
# Posted By Adrian Parr | 9/8/09 3:50 PM
Hi Stefan,

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
# Posted By Adrian Parr | 9/8/09 3:53 PM
Admittedly this is annoying and I'd love to find a way to get rid of it. That's a lot to say for the guy who made this behavior - but we're completely handcuffed by the amount of former 'magic' that FMS baked in for FLVs - no file type, no extensions and then we're thrust into a world with 4+ types to play, and mp4s can have any extension. Next version of a media server, everything needs an extension - no magic please. It's still annoying though, no doubt
# Posted By Asa Whillock | 10/26/09 4:21 PM