View Full Version : Script for a video 'play' command.
Signal
10-29-2007, 03:03 PM
I'm trying to find a script that, when I press the left directional key on the keyboard, it'll trigger a video to start playing. The instsance of the FLVPlayback control is named trigVid1, and the video is titled Video020.flv, and is in the same directory as the .fla is saved.
I've gone through loads of tutorials, but I've not found any specifically for this, and I don't have enough understanding of ActionScript to put it together from what they do say.. :confused:
What would this script be, and where should it be attached?
Thanks in advance...
atomic
10-29-2007, 03:27 PM
Make sure the autoPlay parameter is set to false, and add this on the main timeline on a frame where the player is present on stage...
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
trigVid1.contentPath = "Video020.flv";
trigVid1.play();
}
};
Key.addListener(listen);
Signal
10-29-2007, 03:40 PM
Aha! Brilliant, thank you.
A couple of quick followup questions, if you've got the time? As it is, that'll only play the video through once. How can I get it so that futher presses restart the video again - even interrupting it if it's already playing?
atomic
10-29-2007, 03:57 PM
Quick & dirty?
I'd say...
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
trigVid1.contentPath = "Video020.flv";
trigVid1.stop();
trigVid1.play();
}
};
Key.addListener(listen);
Signal
10-29-2007, 04:19 PM
Ah, thanks...
Is there a... long and clean way to do it? Because that sometimes has delays before starting to play again, sometimes several seconds between keypress and playback starting.
For reference, I've assigned another video to the Right directional button, and there are two other videos playing, controlled by the timeline.
For this project, it doesn't matter in the least whether it's optimised for the web, because it won't be displayed online. It could be gigabytes in size, as long as it responds quickly... which is quite important.:eek:
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
trigVid1.contentPath = "Video020.flv";
trigVid1.stop();
trigVid1.play();
}
};
Key.addListener(listen);
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.RIGHT) {
trigVid2.contentPath = "Video021.flv";
trigVid2.stop();
trigVid2.play();
}
};
Key.addListener(listen);
atomic
10-29-2007, 04:50 PM
Locally? I'm not experiencing any significant delay on one key only... Were you, before setting the second key listener?
Signal
10-29-2007, 05:06 PM
I took out the second listener, and it's still there. In fact after a while it seems to stop responding at all.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.