473,748 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to select play 1 of 5 songs using Javascript?

Con
Hi, I'm getting the following error message in the JavaScript console:

Error: mus has no properties
Source File: file:///G:/temp/cafedub.htm
Line: 35

Now, I would like to script to work in both IE 6 and Netscape 7. The
goals of the script are as follows:

o when a music image is clicked, please the associated music without
looping
o if the same image is clicked again, then that music stops playing
o if another image is clicked, then it should stop all others and play
the
currently selected music link
o the script should play in the background while the page is displayed

BEGIN SCRIPT:

<script>

var musi;
var mus;
var songs = new Array();

songs[0] = "mp3/burt_lick_the_l ishna_weenay.mp 3";
songs[1] = "mp3/mouse_cant_tap. mp3";
songs[2] = "mp3/cool_and_keen,m p3";
songs[3] = "mp3/hollywood_poser _blues.mp3";
songs[4] = "mp3/suction_boy.mp3 ";

var isOn = new Array();

isOn[0] = false;
isOn[1] = false;
isOn[2] = false;
isOn[3] = false;
isOn[4] = false;

function mus1( musicNumber )
{
musi = songs[ musicNumber ];

if ( !isOn[ musicNumber ] ) {
mus.innerHTML=" <embed src="+musi+" loop=-1>";
isOn[ musicNumber ] = true;
}
else {
mus.innerHTML = "";
isOn[ musicNumber ] = false;
}
}

document.write( "<span id='mus'
style='position :absolute;top:-90000'><embed src="+musi+" width=0
height=0 loop=-1></span>");

END SCRIPT:

BTW, my links are developed as follows:

<a id="mus" href="javascrip t:void(0)" onclick="mus1( 2 )"><img
src="sound.gif"
width="16" height="16" border="0"></a>

If anyone has any ideas as to how to resolve this issue, please post to
the group.

Thanks in advance,

-Conrad

Jul 23 '05 #1
2 2664
Con <co******@runbo x.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hi, I'm getting the following error message in the JavaScript console:

Error: mus has no properties
Source File: file:///G:/temp/cafedub.htm
Line: 35

Now, I would like to script to work in both IE 6 and Netscape 7. The
goals of the script are as follows:

o when a music image is clicked, please the associated music without
looping
o if the same image is clicked again, then that music stops playing
o if another image is clicked, then it should stop all others and play
the
currently selected music link
o the script should play in the background while the page is displayed

BEGIN SCRIPT:

<script>

var musi;
var mus;
var songs = new Array();

songs[0] = "mp3/burt_lick_the_l ishna_weenay.mp 3";
songs[1] = "mp3/mouse_cant_tap. mp3";
songs[2] = "mp3/cool_and_keen,m p3";
songs[3] = "mp3/hollywood_poser _blues.mp3";
songs[4] = "mp3/suction_boy.mp3 ";

var isOn = new Array();

isOn[0] = false;
isOn[1] = false;
isOn[2] = false;
isOn[3] = false;
isOn[4] = false;

function mus1( musicNumber )
{
musi = songs[ musicNumber ];

if ( !isOn[ musicNumber ] ) {
mus.innerHTML=" <embed src="+musi+" loop=-1>";
isOn[ musicNumber ] = true;
}
else {
mus.innerHTML = "";
isOn[ musicNumber ] = false;
}
}

document.write( "<span id='mus'
style='position :absolute;top:-90000'><embed src="+musi+" width=0
height=0 loop=-1></span>");

END SCRIPT:

BTW, my links are developed as follows:

<a id="mus" href="javascrip t:void(0)" onclick="mus1( 2 )"><img
src="sound.gif"
width="16" height="16" border="0"></a>

If anyone has any ideas as to how to resolve this issue, please post to
the group.

Thanks in advance,

-Conrad


The variable 'mus' has nothing assigned to it, therefore the error message
is correct.

--
S.C.

Jul 23 '05 #2
Con
Hi, is there a 'this' pointer or something that they can reference
within these blocks?

Thanks,

-Conrad

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2328
by: charbonneau | last post by:
I need to develop a WinForm application which can play .mp3 music files stored on another machine on a LAN. This applicaiton needs to run on servaral different client machines at the same time. I want to have complete control over the UI - no visibly embedded Media Player if possible. I also need to be able to programatically stop/play/pause/resume/change volume/change songs. Any ideas on how to do this? Do I need some sort of...
4
8841
by: mr_burns | last post by:
hi, using javascript, how do i select an option in a combo box? i have tried looking on the internet but dont really know what i should be searching for. what i want to happen is that when a function is called a line of code will select a specific option in a combo box. something like: //excuse the dodgy syntax
2
2186
by: Keyser | last post by:
On most my pages, I use Javascript to play a sound. It works fine in Netscape 4.7, Netscape 7.2, Firefox 1.0, IE5 and IE6 using Windows98 as the operating system. However, using WindowsXP as the operating system, the entire Netscape 7.2 browser and Firefox 1.0 browser shuts down when I try to use the Back button on these pages. Is there some setting in Windows XP that is causing this or is there something I can add to the Javascript to...
1
2385
by: Eric Trav | last post by:
Hello, I am using mozilla and javascript to change the style background color for my select with onfocus() and back to white with onblur(). When i process onfocus(); i have to click on the select three times to get the popup menu and everything seems slow. No errors are reported in the console however it seems as if the click event is not being processed after the focus event is processed.
3
6305
by: kmurali | last post by:
can any one knew how to play a vedio or songs in a frame using javascript
13
4901
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives, suggestions or improvements? if( wmv file) document.write("<OBJECT id=Player classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 height="354" width="479">
3
2927
by: matwilko | last post by:
hi, i am trying to create a simple version of itunes...and i am using iframes to do this. I have already set up the iframes using dreamweaver and used a drop-down menu to select the genre. When selecting the genre the artists appears in iframe1...and i want to be able to select the artist so that the songs appear. I am unsure of how to do this, could anybody help? Thanks Here is my current code... <html> <head> <title>MiTunes</title>...
26
3902
by: Jake Barnes | last post by:
I did a search on the newsgroup comp.lang.javascript. I was searching for "how to play a sound with Javascript". I'm somewhat suprised that the majority of entries are from the 1990s, and there are almost no posts from the last 3 years: http://groups.google.com/group/comp.lang.javascript/search?group=comp.lang.javascript&q=how+to+play+a+sound+with+Javascript&qt_g=Search+this+group Even after sorting by date, there don't appear any...
27
17681
by: davidson1 | last post by:
Hai friends..... I am using Compaq Laptop..I used to hear songs most of the time...but suddenly when i open the Windows Media Player to hear the songs..it is not singing..but gives me the following error.... Windows Media Player cannot play the file because there is a problem with your sound device. There might not be a sound device installed on your computer, it might be in use by another program, or it might not be functioning properly....
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.