Playing a video from an RTMP server using the Spark VideoPlayer control in Flex 4

by Peter deHaan on December 14, 2009

in VideoPlayer (Spark), beta2

The following example shows how you can load a recorded F4V video from an RTMP server in a Spark VideoPlayer control in Flex 4 by setting the source property to a DynamicStreamingVideoSource object.

Full code after the jump.

The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 beta, check out the Adobe Flash Builder 4 page on the Adobe Labs site. To download the latest build of the Flex 4 SDK, see http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4. For instructions on using the beta Flex 4 SDK in Flex Builder 3, see "Using the beta Flex 4 SDK in Flex Builder 3".

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/12/14/playing-a-video-from-an-rtmp-server-using-the-spark-videoplayer-control-in-flex-4/ -->
<s:Application name="Spark_VideoPlayer_DynamicStreamingVideoSource_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark">
 
    <s:VideoPlayer id="vidPlyr"
            loop="true"
            muted="true"
            left="100" right="100"
            top="100" bottom="100"
            horizontalCenter="0" verticalCenter="0">
        <s:source>
            <s:DynamicStreamingVideoSource host="rtmp://fmsexamples.adobe.com/vod/" streamType="recorded">
                <s:DynamicStreamingVideoItem streamName="mp4:_cs4promo_1000.f4v" />
            </s:DynamicStreamingVideoSource>
        </s:source>
    </s:VideoPlayer>
 
</s:Application>

This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.

{ 2 comments… read them below or add one }

1 Bruce Hopkins December 30, 2009 at 11:49 am

FYI,

I have the Flash Builder 4 Beta 2, and this this example does not work at all. The “DynamicStreamingVideoSource” class is not in the API.

Reply

2 Peter deHaan December 30, 2009 at 11:58 am

@Bruce Hopkins,

Yeah, the Flex 4 Beta 2 SDK build is relatively “old” now. I always use the nightly builds as they contain oodles of bug fixes and the latest and/or greatest code.

To download the latest build of the Flex 4 SDK, see http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.

Peter

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: