views:

39

answers:

0

Hello all,

I'm trying to play an FLV using the Netstream class - standard stuff, really using nothing more complex than things you can find in the help files. I've created a control panel with a bar you can use to click and drag and scrub through the video.

Exporting to Flash Player 9, it's working fine and I can scrub through the video, but only while the FLV is still loading. As soon as it hits 100% the scrubbing (using Netstream.seek()) becomes incredibly unresponsive, almost to the point of crashing the player.

I've killed all ENTER_FRAMES, removed all unnecessary listeners and nullified everything I can think of but something massively resource-intensive seems to be kicking in as soon as the load finishes.

Has anyone ever seen this? I've never come across this and can't find anything similar across assorted forums.

Code below but I don't think the mouse-move drag actions are the problem! Fine in the Flash CS4 IDE, broken in the browser.

Thanks for any help you might be able to provide,

Gareth

    // Drag
    private function dragVideo(e:MouseEvent):void {

        // Match the x position of the dragger to the x position of the mouse
        videoControls.progressBar.dragger.x = videoControls.progressBar.barInner.mouseX;

        // If this results in the dragger moving outside the dragging area, constrain it
        if (videoControls.progressBar.dragger.x < videoProgressRectangle.left) {
            videoControls.progressBar.dragger.x = videoProgressRectangle.left;
        } else if (videoControls.progressBar.dragger.x > videoProgressRectangle.right) {
            videoControls.progressBar.dragger.x = videoProgressRectangle.right;
        }

        // As the dragger moves, work out its position as a percentage of the total distance it CAN move
        // That distance is the width of the black inner bar but you must also accomodate the centred registration point of the dragger
        // So knock off half the dragger's width from it's current position (which gives the left edge of the inner bar)
        // Then knock off the dragger's width minus the 2px overhang of the white progress bar border, from the total draggable distance
        videoSeekPercentageMouse = (videoControls.progressBar.dragger.x - (videoControls.progressBar.dragger.width / 2)) / (videoControls.progressBar.barInner.width - (videoControls.progressBar.dragger.width - 2));

        // Now use that percentage to seek the video to the equivalent percentage of its total time
        if (videoSeekPercentageMouse <= 0) {
            videoNetStream.seek(0);
        } else if (videoSeekPercentageMouse >= 1) {
            // Because video metaData says the length is xyz while the real length is xyz + 0.015,
            // seek to slightly before the end 
            videoNetStream.seek(videoDuration - 0.016);
        } else {
            videoNetStream.seek(videoDuration * videoSeekPercentageMouse);
        }

        // Show the video's current progress
        videoControls.progressBar.barProgress.scaleX = videoSeekPercentageMouse;

        // After the mouse moves update the display
        e.updateAfterEvent();

    }