New and improved startPlay control
February 18th, 2008 . by polyGeekThe 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.







Dan,
This is cool. Is it possible to set an offset as to which ’snapshot’ is taken as the representative image? I know many videos have a black screen to start so, I would like to be able to pass a variable that would take the snapshot from however many seconds in I specify.
So in other words, I specify maruSnap=5; and the bitmap image shown is a frame 5 seconds into the clip.
Can we do this?
Thanks!
Banta67
@Banta67, Yep, that would be pretty cool. I’ve added it to the Suggestions page. It’s been a pain in the ass to get that to work properly with RTMP streams. Hopefully it won’t be problematic to add the delay.