Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-16-2013, 12:39 PM   PM User | #1
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
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)
tpeck is offline   Reply With Quote
Old 01-16-2013, 01:03 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by tpeck View Post
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.
Philip M is offline   Reply With Quote
Old 01-16-2013, 01:27 PM   PM User | #3
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
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)
tpeck is offline   Reply With Quote
Old 01-16-2013, 02:56 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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..
Philip M is offline   Reply With Quote
Old 01-16-2013, 04:35 PM   PM User | #5
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
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..
xelawho is offline   Reply With Quote
Users who have thanked xelawho for this post:
tpeck (01-17-2013)
Old 01-16-2013, 06:19 PM   PM User | #6
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
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.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 01-17-2013, 08:28 AM   PM User | #7
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
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)
tpeck is offline   Reply With Quote
Old 01-17-2013, 08:30 AM   PM User | #8
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
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)
tpeck is offline   Reply With Quote
Old 01-17-2013, 11:43 PM   PM User | #9
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,993 Times in 3,962 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 01-18-2013, 01:10 AM   PM User | #10
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by tpeck View Post
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).
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 01-20-2013, 07:47 AM   PM User | #11
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
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..
tpeck is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:52 PM.


Advertisement
Log in to turn off these ads.