Tag Archive | "adobe flash"

Tags: , , , , ,

osmf sprint 8 example player

Posted on 07 January 2010 by nathan

I have started working with Adobe’s Open Source Media Framework. To get started I hunted down some examples to see how others dove into it – and found a few great ones, but most that relied on previous sprints. As you may or may not know, OSMF is still in prerelease which means that anything could change, and for traits that is exactly what happened between sprint 7 and sprint 8.

This change (along with some others) made many of the examples that i found not work – including a good one from @lisamarienyc on the adobe forums that I thought was best.

So I rewrote some portions and the resulting code is below:
questions, corrections, comments, and suggestions welcome.

package {

import flash.display.Sprite;
import org.osmf.events.LoadEvent;
import org.osmf.events.MediaError;
import org.osmf.events.MediaErrorEvent;
import org.osmf.events.MediaErrorCodes;
import org.osmf.events.MediaPlayerCapabilityChangeEvent;
import org.osmf.media.MediaPlayer;
import org.osmf.media.URLResource;
import org.osmf.net.NetLoader;
import org.osmf.traits.LoadState;
import org.osmf.traits.MediaTraitType;
import org.osmf.video.VideoElement;
import org.osmf.utils.URL;

public class OSMFExampleTwo extends Sprite {

	//our local flv to be played
    private const PROGRESSIVE:String = "trailer.flv";  //path to your progressive flv here

    private var _player:MediaPlayer;
	private var _video:VideoElement;

    public function OSMFExampleTwo() {
        trace("initialized");

		//create a new media player
		_player = new MediaPlayer();
        _video = new VideoElement(new NetLoader(), new URLResource(new URL(PROGRESSIVE)));

		//add an event listener to the video element to catch netstream failed errors
		_video.addEventListener(MediaErrorEvent.MEDIA_ERROR, onLoadEvent);

		//add an event listener so that when the player is capable of being viewed we can add it to the display list and watch
		_player.addEventListener( MediaPlayerCapabilityChangeEvent.VIEWABLE_CHANGE, onViewable );

		//add a new video element to the player
	   	_player.element = _video;

        }

	   //if the event fails - what comes through:

        private function onLoadEvent( e:MediaErrorEvent) :void {
           trace('ERROR (onLoadEvent): recieved a media error event');

		   var errorCode = e.error.errorCode;
		   	switch (errorCode) {
				case MediaErrorCodes.STREAM_NOT_FOUND:
					trace('ERROR (onLoadEvent): there was an error finding the file that was specified');
					break;
				case MediaErrorCodes.PLAY_FAILED:
					trace('ERROR (onLoadEvent): playback has failed');
					break;
				case MediaErrorCodes.NO_SUPPORTED_TRACK_FOUND:
					trace('ERROR (onLoadEvent): there was no supported track found');
					break;
				case MediaErrorCodes.FILE_STRUCTURE_INVALID:
					trace('ERROR (onLoadEvent): the file structure is invalid');
					break;
			}
        }

        private function onViewable( e:MediaPlayerCapabilityChangeEvent ) :void {
            if( e.enabled ) {
                addChild( _player.view );
                trace('player view');
            }
        }
    }
}

Comments (3)

Tags: , ,

The future relevance of adobe flash

Posted on 27 August 2009 by nathan

In my industry, flash is king. It is the one thing that combines all of us in this ecosystem rather seamlessly and the giver of our core ability: the ability to watch online video.

Sure there are other systems, html5 delivers video directly through the browser but much of the capability for innovation and interactivity is lost. Not to mention that there are few ways to tie events and other technologies to html5 video (someone is developing a html5 video ad delivery system, right?).

Html5 video is (for the time being) the exception rather than the rule – especially with all the infighting over codec standards. (Although google’s recent aquisition of on2 technologies could make one of the sweetest codecs available to all).

However, for the most part – adobe’s flash remains the standard method of delivery for the majority of onlne video we watch today.

With all that in mind we can see why the flash platform is so successful and is growing in many ways – especially exciting is the air platform.

But for the life of me I cannot find another application that *requires * flash. The web has (like it or not) moved to html strict compliant interfaces that make use of javascript to deliver interactivity that is as impressive within the desktop browser as it is on the mobile phone (another place flash is strikingly absent). In most of the ways in which it is applied – alternative technologies could easily be employed to create the same experience and functionality.

Online video is currently the saving grace for this technology, the only place where flash is crucial and necessary. Once video is adopted as a standard element – what will become of the flash platform?

In order for air to be taken seriously it will have to get real hooks into the operating system, requiring more trust from the user – but opening a lot of opportunity for flash developers to build *real* desktop applications as opposed to dektop based web interfaces.

Without a clear definitive direction from adobe I will be delving into javascript.

Comments (0)

Photos from our Flickr stream

See all photos