|
SYS-CON.TV Webcasts
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Top Links You Must Click On
Flex Video Rock 'n Roll With Flex 2
Flex 2 and the Flash Media Server are a match made in heaven
By: Michael Givens
Aug. 6, 2007 08:45 PM
Flex 2 and the Flash Media Server are a match made in heaven. By combining the two technologies, streaming Flash videos at my office has become a nice part of my daily routine and a good excuse to add another monitor to my desktop. Whether your musical genre taste is classical or rock 'n roll, it's relatively easy to quickly create a desktop library of Flash videos. In this article, I'll describe one approach that will have you streaming in no time.
Stepwise, first create a new Flex 2 project in the Flex 2 Builder IDE (for this project there's one named fmsvideo_flex). The code and the explanation for the main MXML file are discussed below (see Listing 1). The application is initialized with the initApp()1 function where the VideoDisplay control is displayed and the HttpService is called. This accomplishes two main things. First, Flex creates a VideoDisplay control (http://livedocs.macromedia.com/flex/201/langref/mx/controls/VideoDisplay.html) with no visible user interface; by setting the source attribute to an flv and the autoPlay attribute to false, the control gets displayed in the UI. Second, the data (see Listing 2) for the ComboBox video list is requested. The creationComplete attribute includes a call to the PageLoaded()2 function that kicks off, at one-second intervals, a function that determines if the HttpService is complete; the readytoContinue()3 function loads the videos' names and labels into an array, dp, that is the dataProvider of the ComboBox control, cbxVideos.
The standard Play, Mute, Pause and Stop buttons are included, providing complete playback control. Utilizing an EventListener, vidDisplay.addEventListener(Event.COMPLETE, onComplete)5 , the buttons are enabled or disabled in a logical fashion depending on the video's playback state. This article would not be complete without discussing the placement of the Flash video flvs. You should create a new Flash Media Server application - by adding new folders (for this demo, videos\streams\_definst_) in the applications folder (for a default installation, you would end up with this folder: "C:\Program Files\Macromedia\Flash Media Server 2\applications\videos\streams\_definst_"). Copy the flvs and paste them here. If you need some flvs for your VideoPlayer, you can grab the URLs from YouTube.com and use a tool you'll find at TechCrunch - www.techcrunch.com/get-youtube-movie/. This effectively allows you to download the flvs of your choice. I hope you found this article useful. If you have any follow-up questions, feel free to ping me at the e-mail address listed with this article. Rock on! Reader Feedback: Page 1 of 1
Enterprise Open Source Magazine Latest Stories . . .
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||