Enjoy an ad free experience by logging in. Not a member yet?
Register .
01-16-2013, 12:39 PM
PM User |
#1
Regular Coder
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
alert as a time delay
This is a bit odd. The sound will play and then go to the video (which is what I want) but only if I include the alert!
Code:
soundManager.play('scratch','../../media/mp3/scratch.mp3');
alert("why do you need me?");
document.writeln("<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\" width=\"480\" height=\"336\">");
document.writeln("<param name=\"src\" value=\"file:///"+driveletter+":/MEDIA/VIDEO/Lesson27.mov\">");
document.writeln("<embed width=\"480\" height=\"336\" type=\"video/quicktime\" pluginspage=\"http://www.apple.com/quicktime/download/\" src=\"file:///"+driveletter+":/MEDIA/VIDEO/Lesson27.mov\" controller=\"true\" autoplay=\"true\" scale=\"aspect\"></embed>");
document.writeln("<param name=\"controller\" value=\"true\">");
document.writeln("<param name=\"autostart\" value=\"true\">");
document.writeln("<param name=\"scale\" value=\"aspect\">");
document.writeln("</object>");
}}
If I take out the alert, the sound gets bypassed.
How can I get rid of the alert and have the sound play then go to the video?
Something about giving the sound enough time to play?
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
01-16-2013, 01:03 PM
PM User |
#2
Supreme Master coder!
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Quote:
Originally Posted by
tpeck
This is a bit odd. The sound will play and then go to the video (which is what I want) but only if I include the alert!
Code:
soundManager.play('scratch','../../media/mp3/scratch.mp3');
alert("why do you need me?");
document.writeln("<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\" width=\"480\" height=\"336\">");
document.writeln("<param name=\"src\" value=\"file:///"+driveletter+":/MEDIA/VIDEO/Lesson27.mov\">");
document.writeln("<embed width=\"480\" height=\"336\" type=\"video/quicktime\" pluginspage=\"http://www.apple.com/quicktime/download/\" src=\"file:///"+driveletter+":/MEDIA/VIDEO/Lesson27.mov\" controller=\"true\" autoplay=\"true\" scale=\"aspect\"></embed>");
document.writeln("<param name=\"controller\" value=\"true\">");
document.writeln("<param name=\"autostart\" value=\"true\">");
document.writeln("<param name=\"scale\" value=\"aspect\">");
document.writeln("</object>");
}}
If I take out the alert, the sound gets bypassed.
How can I get rid of the alert and have the sound play then go to the video?
Something about giving the sound enough time to play?
Try wrapping the code for the video in a function with setTimeout with a couple of seconds delay.
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
01-16-2013, 01:27 PM
PM User |
#3
Regular Coder
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
It's weird Philip.
Code:
soundManager.play('scratch','../../media/mp3/scratch.mp3');
alert("why do you need me?");
vid2();
//setTimeout('vid2()',3000);
}}
function vid2(){
document.writeln("<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\" width=\"480\" height=\"336\">");
document.writeln("<param name=\"src\" value=\"file:///"+driveletter+":/MEDIA/VIDEO/Lesson27.mov\">");
document.writeln("<embed width=\"480\" height=\"336\" type=\"video/quicktime\" pluginspage=\"http://www.apple.com/quicktime/download/\" src=\"file:///"+driveletter+":/MEDIA/VIDEO/Lesson27.mov\" controller=\"true\" autoplay=\"true\" scale=\"aspect\"></embed>");
document.writeln("<param name=\"controller\" value=\"true\">");
document.writeln("<param name=\"autostart\" value=\"true\">");
document.writeln("<param name=\"scale\" value=\"aspect\">");
document.writeln("</object>");
}
The only one of the three tries above that plays the sound and advances to the video is the alert!
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
01-16-2013, 02:56 PM
PM User |
#4
Supreme Master coder!
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Try a longer timeout period.
Note than an alert() suspends program execution but setTimeout() does not - it just delays the execution of the function.
Look into your code with that in mind.
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 01-16-2013 at 03:21 PM ..
01-16-2013, 04:35 PM
PM User |
#5
Senior Coder
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
I'm not familiar with soundManager (I'm guessing it's a plug-in), but many audio players have event listeners built in. You could investigate the soundManager documentation, see if it has an "onuadioended" (or similar) event, and when that fires, call a function to run your video
[EDIT]: If this is the same one you're using, the onfinish event at this link may prove useful:
http://www.schillmania.com/projects/soundmanager2/doc/
Last edited by xelawho; 01-16-2013 at 04:37 PM ..
Users who have thanked xelawho for this post:
01-16-2013, 06:19 PM
PM User |
#6
Master Coder
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
Note that document.writeln is as dead as Netscape 4 (the last browser that needed it) and since then alert has been repurposed as a debugging tool - so neither statement should appear in a live script.
01-17-2013, 08:28 AM
PM User |
#7
Regular Coder
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
Thank you xelawho.
It turned out to be 'onfinish' which worked.
I have learnt to read the screed for the plugins, but I must confess, I would not have been likely to find that solution - even having read up on it.
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
01-17-2013, 08:30 AM
PM User |
#8
Regular Coder
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
felgall, is there an alternative to document.writeln (besides document.write)?
How else could you make the video play?
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
01-17-2013, 11:43 PM
PM User |
#9
Supreme Master coder!
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,993 Times in 3,962 Posts
Why so you need to use JS to create that <object>...</object> code? Why can't you just drop it in the HTML without using JS at all?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
01-18-2013, 01:10 AM
PM User |
#10
Master Coder
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
Quote:
Originally Posted by
tpeck
felgall, is there an alternative to document.writeln (besides document.write)?
How else could you make the video play?
using documentGetelementById and innerHTML works for all current browsers as well as older browsers such as IE5.
Alternatively you could use the proper DOM commands such as createElement and insertChild to create and add HTML tags from JavaScript.
Of course the simplest way where the tags are not being changed after the page loads is to simply hard code them in the HTML.
write and writeln can only output to the page before it finishes loading so anything those commands can do can be done using HTML without JavaScript unless the values to be output are being generated (in which case a server side language would be more appropriate).
01-20-2013, 07:47 AM
PM User |
#11
Regular Coder
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
OP, I have to use the document.write method because an inline frame is being called and depending on a cookie (giving the disk drive letter), the video being played is either streamed across the web or played from a disk.
However, I will investigate felgall's advice and see if I can get that working as an alternative. Not sure how that would work though...
I've made a demo at:
http://aapress.com.au/demo/diskorstream/page1.html
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
Last edited by tpeck; 01-20-2013 at 07:57 AM ..
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 05:52 PM .
Advertisement
Log in to turn off these ads.