A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Video playback questions

  1. #1
    Junior Member
    Join Date
    Apr 2006
    Posts
    29

    Video playback questions

    Hi there,

    I have a couple of questions with regards to video playback in Flash using AS 3.

    I'm not very good with flash coding so I've used the default video importer to import the video (file > import > import video). However I'm trying to put an event handler in that will detect when playback has completed and then take the viewer back to the main menu. I know it has something to do with NetStatusEvent but not sure how to connect it with the video.

    Additionally when a viewer is watching a video, if they click a button below the video it takes them, say, back to the main menu. However the video continues to play in the background. I have put a 'video.pause();' on any button that takes the viewer away from the video, however the video is still loading in the background which isn't the ideal.

    Any help with this would be appreciated

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    You're probably dealing with a FLVPlayback component. Try listening for the video to complete:

    PHP Code:
    import fl.video.VideoEvent;

    yourVideo.addEventListener(VideoEvent.COMPLETEonVideoFinished);

    function 
    onVideoFinished(e:VideoEvent):void{
        
    //  go back to main menu

    And to stop the loading:

    PHP Code:
    try{
    yourVideo.stop();
    yourVideo.closeVideoPlayer(0);
    } catch(
    err:Error){} 
    Please use [php] or [code] tags, and mark your threads resolved 8)

  3. #3
    Junior Member
    Join Date
    Apr 2006
    Posts
    29
    Quote Originally Posted by neznein9 View Post
    You're probably dealing with a FLVPlayback component. Try listening for the video to complete:

    PHP Code:
    import fl.video.VideoEvent;

    yourVideo.addEventListener(VideoEvent.COMPLETEonVideoFinished);

    function 
    onVideoFinished(e:VideoEvent):void{
        
    //  go back to main menu

    And to stop the loading:

    PHP Code:
    try{
    yourVideo.stop();
    yourVideo.closeVideoPlayer(0);
    } catch(
    err:Error){} 
    Thanks for that, the first one worked beautifully. The second one though, not so well. I get the error message
    Code:
    VideoError: 1007: Cannot delete default VideoPlayer
    	at fl.video::FLVPlayback/closeVideoPlayer()
    	at workshop_fla::MainTimeline/playbtnMain()
    I've nested your code into my button function which is either loading a new video or returning to the main menu which should stop playback & close the video. This is how it currently is...

    Code:
    function playbtnMain(evt:MouseEvent):void
    {
    	video.stop();
    	video.closeVideoPlayer(0);
    	gotoAndStop(5, "Main");
    }
    Any ideas?

  4. #4
    _marlo machka
    Join Date
    Jan 2006
    Posts
    30
    use:
    video.getVideoPlayer(0).close();

    instead of video.closeVideoPlayer(0)

  5. #5
    Junior Member
    Join Date
    Apr 2006
    Posts
    29
    Quote Originally Posted by okdust View Post
    use:
    video.getVideoPlayer(0).close();

    instead of video.closeVideoPlayer(0)
    That worked - as in it didn't generate an error message and appears to remove the video and stop it from caching. Many thanks! There is still another problem, the video stays on screen, however this only happens after the fullscreen button has been pushed, followed by pushing escape (to get out the the fullscreen) and then the 'main menu' button is pushed. If I disable the fullscreen option, it works fine and the video is cleared off the screen. On frame 1 I have the video (first play) and when someone clicks the menu button it takes them to frame 5.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center