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');
}
}
}
}
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.
Posted on 27 June 2009 by nathan
just a quick note on scaling in as:
myMovieClip_MC.width = 300;
myMovieClip_MC.scaleY = myMovieClip_MC.scaleX;
Posted on 24 August 2008 by nathan
I have been fascinated with tag clouds for about two days now and in a recent search for a flex badge ran across this post for what i don’t knOw. But it sparked an idea…
Continue Reading
Posted on 20 August 2008 by nathan
I love the badges on the flexexamples.com and was disappointed to see there was no online creator that did as good of a job. Being the lazy programmer that I am I am thinking it would be nice to create an air app that pulls the favicon and allows you to resize and position it (or select one from your HD), specify a bg color or gradient and save…
Continue Reading
Posted on 20 August 2008 by nathan
I would love to see an application that aggregrated all of the pics I send to twitpic and put them in a rotating flash gallery I can embed on my blog, myspace, facebook, whatever. when I send my pic up via email, I would assume contextual ads could be pulled from an ad database and unobtrusively placed within the context of the image to generate some revenue. Putting all of my pics in one place would make for a nice visual on my site or social space. Add commenting that was within A central app, so the comments followed the branded image viewer wherever it went and we may have a business model…
Continue Reading
Posted on 08 August 2008 by nathan
Every mornig at blip, Aaron does a search on twitter to see who is saying what about us – which is great, because we then respond to these comments with tips, features, or a simple thanks. Since my head is loaded with air uses these days, and I’m knee deep in flex – I wondered if it would be worth it to create a small application that would search twitter for the given keywords, and upon returning results – store them in a dB somewhere so we can reference them later – I know a twitter search is an easy thing to do – but I like building compnents to make things desktopable. So if each one of these was assigned a status in the dB, and everyone in the office was connected to this dB via the little app – we could respond to users, and check off the items that were “done” , with the username of the person who responded set. Helping us keep track of user issues, feature requests, etc – and a manageable unobtrusive interface for doing so. Just a thought…
Continue Reading
Posted on 08 August 2008 by nathan
One of my favorite things about using the tablet PC was the ability to grab a screen shot of a web page and pull it into oneNote, allowing me to draw directly on top of the page. This made understanding the changes that needed to be bade greatly more simple in that you saw what was to be changed. I abhor the fact that basecamp made me write things like: on the third header down, left column on the home>menuItem>whatever page, change the color to black(#000000). With the tablet – I took a screenshot, imported onto the oneNote “paper” and drew a circle around the item adding a note to “change to black”. When I was all done – I exported as a pdf and sent to my developers. Amazingly this got through most language barriers, and since my snippet always included a URL – it was easy to click to see the actual page I was referring to. My idea is to create an app that would allow me to do the same process, but be sdB tied and based in AIR – this way, the files can be shared, responsibilities could be divvied up, and it would work on any internet connected computer anywhere. Theoretically – I could pull in the content of a page and use flash’s bitmap class to copy the screen. then the user would be presented with a the screenshot and a set of drawing tools. once a note was created on the page – the user could click”make task” and then there would be a reference to the task, who was to handle it, and a visual representation of what was to be done. Inviting others as collaborators to share the same projects, and possibly importing links to these markups within basecamp would make my life CTOing much easier. Would love thoughts, ideas, features, and critiques. Also would love to know if there is anything out there that already does the same – would save me a great deal of time.
Continue Reading