February 18th, 2008 . by polyGeek
The startPlay button has gotten a major update. When you use it it not only pauses the video playback but it also stops the NetStream. Meaning that there is no video downloading until the user begins playback.
That comes in very hand here on my blog where I have multiple videos on the homepage at any given time. I don’t want to needlessly have those videos downloading if the user isn’t going to watch all of them. And that takes a huge burden off my server.
Here’s an example. Watch for the download progressBar closely when you click play. You should see it grow quickly even though the video has been sitting there for a few minutes.
Here’s how it works. For progressive streaming once the NetStream starts downloading a function runs that takes a Bitmap snapshot of the current frame visible in the videoWindow. Then it kills the NetStream so that no more downloading can occur. If everything has worked correctly the user will never know because they will still see one of the first few frames of the video sitting there.
Sometimes the Bitmap snapshot happens before any video is rendered so the user would see a blank screen. I’m working on that.
When the user starts playback the NetStream is recreated and downloading begins.
This should work with RTMP streams as well but there might be a few bugs. And it doesn’t apply to MP3s at all.
Posted by: polyGeek in Controls |
2 Comments »
June 24th, 2007 . by polyGeek
There are a few other controls that don’t really fit into any particular category.
The startPlay button is there for you to create the interface like youTube made popular. You can place this startPlay MovieClip over the videoWindow. When the video loads it will automatically pause - even if the play/pause button has an instance name of play_btn.
When the user clicks the startPlay MovieClip it will vanish and the video will begin playing.
The loop control is very easy to use. It can be a MovieClip or TextField just so long as the instance name is loop. It obviously causes the video to play again when it reaches the end.
The back# control is a shortcut for jumping backward in the video by a set number of seconds. As a for instance. If you created a MovieClip with an instance name of back5 then when the user clicked on it the video would jump back approximately 5 seconds.
Note: Flash video can only seek - jump - to a video keyframe. When you use the seek method() in Actionscript it will seek to the nearest video keyframe. The more keyframes the finer the scrubbing and jumping is but the filesize will be larger.
The buffer# controls how many seconds of video get buffered before playback begins. For instance if you created a MovieClip with an instance name of buffer5 then the first five seconds of the video would buffer before playback begins. This does not mean that it would pause for five seconds. Hopefully it would only take 2-3 seconds to buffer 5 seconds of video. Otherwise you are streaming at about the same rate that the video is playing and playback will likely be choppy. In that case you should re-compress your video file to a lower data rate.
If you would like to enable smoothing for the video then create a MovieClip with an instance name of smoothing. This acts as a sort of smart blur to your video and can improve the apparent quality in some instances. Especially if you are stretching the video’s width/height during playback.
If you would like for the video to pause on the last frame of the video then create a MovieClip, it can be off Stage, with an instance name of pauseOnLastFrame.
For debugging purposes there is another boolean toggle called verbose. If you create a MovieClip with the instance name of verbose it will trace messages to the Flash Authoring tools Output window. This will display things like video status, the various MovieClips that were found, and not found, etc. This will have no effect on display or playback when viewed by your users.
Posted by: polyGeek in Controls |
11 Comments »