Tag Archives: flash cs4

The Simplest Possible OSMF Player

I’m continuing work on my FITC Toronto talk, ‘Standardize Your Flash with Adobe OSMF‘, and the files to accompany it.

OSMF certainly has features and functionality for hard-core developers to build powerful media-rich experiences. But OSMF also makes basic media player code really easy for those users of Flash who might not consider themselves developers, but who still are comfortable coding on the timeline.

One of the issues with the still nascent, but growing at an impressive rate OSMF documentation, is that almost all the sample code is for users of Flex Builder / Flash Builder — and all of the sample code for Flash assumes use of external class files.

But using OSMF does not require coding in external class files. So, to illustrate that point, I’ve gone ahead and modified the simplest possible OSMF video player from Adobe’s documentation to code that works on the timeline. Which I’m posting here.

So this is code (OSMF Sprint 10 v0.93) you can paste onto any timeline that will play video with OSMF.

Want to make it stream the video instead of playing it progressively? Point it to an RTMP URL instead, and it will automatically play.

import org.osmf.containers.MediaContainer;
import org.osmf.elements.VideoElement;
import org.osmf.media.MediaPlayer;
import org.osmf.media.URLResource;
// Create the container class that displays the media. 
var container:MediaContainer = new MediaContainer();
//add the MediaContainer instance to the stage
addChild(container);
// Create the resource to play and point it to the FLV
var resource:URLResource=new URLResource("my.flv");
// Create the MediaElement 
var videoElement:VideoElement=new VideoElement(resource);
//add the VideoElement to our container class
container.addMediaElement(videoElement);
//create the MediaPlayer instance
var mediaPlayer:MediaPlayer = new MediaPlayer();
// Set the MediaElement on a MediaPlayer.  
//Because autoPlay defaults to true, playback begins immediately.
mediaPlayer.media=videoElement;

Share and enjoy!

-r

Comprehensive ActionScript 3 – FREE

As part of their promotion surrounding their new site and new courses, the Rich Media Institute is giving away FREE enrollment in ‘Comprehensive ActionScript 3‘, which is a compilation of five of the online training courses I have published for the RMI.

Enrollment lasts for 90 days, and this course is free to enroll only through February 15th, and only through this link.

‘Comprehensive ActionScript 3′ includes over 9 hours of training, from the following courses:

Practical ActionScript 3
Understanding and Working with Events in ActionScript 3
Understanding and Working with Event Broadcasters in ActionScript 3
ActionScript 3 for Flash Video
The Webcam, CuePoints and Captions in Flash Video with ActionScript 3

So, go ahead and do yourself a favor, and enroll.

Share and enjoy!

-r

OSMF 0.9 Updated Flash CS4 Sample

While I’ve been away from the blog in the past several weeks, it seems that there have been two iterations of the Open Source Media Framework — the last course I wrote was in OSMF7 and now we’re at 9.

And, of course, between these two versions, the sample code in my courses posted at Adobe has become unusable.

After getting a few email requests from developers, I decided tonight to sit down and update the files for the first course — the course in building a progressive video player in OSMF.

So, if you would like, you can get that update here.

The primary difference is that basically EVERY EVENT has changed names and types. So I had to hunt them down through the documentation, one at a time — which I did. And also, they changed the name of the media player instance — again — this time, to ‘media’ (nee ‘player’, nee ‘element’).

Please note that I didn’t really update the comments to reflect the changes to the event names and locations.

And if you’re all very, very, very nice, I might consider updating the files for the Dynamic Multibitrate Streaming Player also ;)

Share and enjoy!

-r