I'm putting together a very basic example to get people started with OSMF, to demonstrate how to play a video and listen for some events, just in an AS3 class in Flash CS4. Having some trouble. I've referenced as many examples as I can find, and have come up with the following example which initializes, but then does nothing. No errors thrown.?I am a bit rusty, to be honest, so it's likely something simple... Any help or advice greatly appreciated. (also attached source)
package {
import flash.display.Sprite;
import org.openvideoplayer.events.LoadableStateChangeEvent;
import org.openvideoplayer.events.MediaPlayerCapabilityChangeEvent;
import org.openvideoplayer.media.MediaPlayer;
import org.openvideoplayer.media.URLResource;
import org.openvideoplayer.net.NetLoader;
import org.openvideoplayer.traits.ILoadable;
import org.openvideoplayer.traits.LoadState;
import org.openvideoplayer.traits.MediaTraitType;
import org.openvideoplayer.video.VideoElement;
import org.openvideoplayer.utils.URL;
public class OSMFExampleTwo extends Sprite {
?private const PROGRESSIVE:String = ''tyra-clip_1_VP6_768K.flv'';
?private var _player:MediaPlayer;
?
?public function OSMFExampleTwo() {
?trace(''initialized'');
?_player = new MediaPlayer();
?_player.addEventListener( MediaPlayerCapabilityChangeEvent.VIEWABLE_CHANGE, onViewable );
?_player.source = new VideoElement( new NetLoader(), new URLResource(new URL(PROGRESSIVE)));
?var loadable:ILoadable = _player.source.getTrait( MediaTraitType.LOADABLE ) as ILoadable;
?loadable.addEventListener( LoadableStateChangeEvent.LOADABLE_STATE_CHANGE, onLoaded );
?}
?
?private function onLoaded( e:LoadableStateChangeEvent ) :void {
?if( e.newState == LoadState.LOADED ) {
?trace( 'load completed' );
?} else if( e.newState == LoadState.LOAD_FAILED ) {
?trace( 'load failed' );
?}
?}
?
?private function onViewable( e:MediaPlayerCapabilityChangeEvent ) :void {
?if( e.enabled ) {
?addChild( _player.view );
?trace('player view');
?}
?}
?}
}
Hi Lisa,
Thanks for trying out the framework! I think the problem is with the local path that you are specifying. If I replace it by a fully qualified one like so:
private const PROGRESSIVE:String = ''file://localhost/Users/edwin/Downloads/osmfexample/tyra-clip_1_VP6_768K.flv'';
then things work. I see no reason why the load state change handler shouldn't be signaling 'LOAD_FAILED' though. It'd be great if you could log a bug on that at http://bugs.adobe.com/jira/ under the 'Strobe' project.
Cheers,
Edwin
PS: the movie you included seems to be blank, audio only?
Trying to get started with OSMFThere is a bug with out relative path handling for URLs on the URLResource.?If you specify your video with a leading ''./'', like this?: ''./tyra-clip_1_VP6_768K.flv''?it should load the video.?You could also use direct http:// or file:// style urls for local files.?Thanks for the feedback!
Ryan O'Connell
OSMF Engineering
Great! This does get a video to load, but its not autoplaying. Isn't that the default behavior?
Thanks
// Lisa
Yes, that's the default behavior.
It did automatically start playing just now when I tried your sample - but we might be on a different version of the framework (I was building from the trunk). If that's not the case, then it'd be great if you could log it as a bug!
Cheers,
Edwin
Actually, I'm now realizing that the sound is playing, but the video is just a black frame.
I'll log a bug.
Glad it's not me!
Thanks for the help.
// Lisa Larson-Kelley
Ah - yes, I'd noticed that too - but I believe this is your FLV. If I play it back with VLC, example, it shows black too. Could you make sure it is not your FLV before you submit?
Thanks!
Edwin
Yep. You're right. I tested a different video and it works fine. Hurrah!
Thank you!
That's great to hear - thanks for letting us know!
Cheers,
Edwin
No comments:
Post a Comment