"Imagination is more important than knowledge." -Albert Einstein

Looping videos in Papervision3D

Posted: November 16th, 2009 | Author: admin | Filed under: papervision3D | No Comments »

I was working on an Augmented Reality bit this weekend which involved a looping video. Normally this is a harmless operation which involves a simple onStreamStatus event, that by passing a “NetStream.Play.Stop” triggers a _netStream.seek(0); function. But when I tried that in PV3d the video would not loop… it was pretty frustrating, but eventually I figured out that the VideoStreamMaterial class in the Papervision3D package stopped rendering upon a “NetStream.Play.Stop” event, but didn’t resume it on a “NetStream.Seek.Notify” event, which I had to manually add.



this is how the function looks like after the change:

private function onStreamStatus ( event:NetStatusEvent ):void
        {
            switch ( event.info.code )
            {
                case "NetStream.Play.Start":
                    animated = true;
                    break;
                case "NetStream.Unpause.Notify":
                    animated = true;   
                    break;
                case "NetStream.Seek.Notify":
                    animated = true;
                    break;
                case "NetStream.Play.Failed":
                    animated = false;
                    break;
                case "NetStream.Play.Stop":
                    animated = false;
                    break;
                case "NetStream.Play.StreamNotFound":
                    animated = false;
                    break;
                case "NetStream.Pause.Notify":
                    animated = false;
                    break;
            }          
        }


Leave a Reply