If you already know about VideoDisplay component, please skip next two paragraphs to see the solution.
VideoDisplay component in Macromedia Flex 2.0 would be replacement of MediaDisplay component in previous versions of Flex. Unlike MediaDisplay component, it doesn’t have any UI controls, it’s a face-less component. It provides you API to control the video playback. So you can build user-interface, controls around it and skin it according to your choice. This was quite difficult with MediaDisplay.
Macromedia Flex 2.0 is still in alpha-phase and if you strongly feel the need of controls, please give us your feedback. We can probably ship it with some default controls.
Anyways, let’s talk about the issue which some people faced while using VideoDisplay with RTMP URLs.
Problem: VideoDisplay component doesn’t play video from a RTMP URL?
For example, following code would compile but won’t work as expected i.e. it won’t play video when application is run.
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*" > <mx:VideoDisplay autoPlay="true" url="rtmp://localhost/videodisplay/intro"/> </mx:Application>
Solution: VideoDisplay is based on Peldi’s FLVPlayer. Like FLVPlayer, it requires a server-side ActionScript file(main.asc) to be placed inside corresponding FlashCom application directory on server.
If you are missing main.asc on server-side, VideoDisplay won’t be able to play videos from a RTMP URL.
You need to place main.asc inside “scripts” folder under your FlashCom application directory. I am taking above code as reference to explain where you can place main.asc. You can see the directory structure of a FlashCom application in following image:
Description about directories shown above:
- videodisplay – this is your application directory on flash-media-server
- scripts – this is the directory where you need to place main.asc and if required, other server-side AS files.
- streams – this is the directory which contains application-instances directories. For example, _definst_ which is default instance directory.
- _definst_ – this directory corresponds to default instance of videodisplay application. In this case, intro.flv is placed inside this directory.
I have uploaded the main.asc on my server so that you can download it from here itself. You can also get the same file from Peldi’s blog, but you need to download the entire FLVPlayer.zip to get main.asc.