473,395 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Start play of Object sound in MZ

As a follow on to the 'fun' I had with IE I'm now trying to play sounds
using an Object tag (no Embed) in MZ. Sadly whenever 'playButton' gets
clicked MZ says that "audObj.Play is not a function":

window.onload = function() {
var audObj = document.createElement("object");
audObj.setAttribute("id", "objmedia");
audObj.setAttribute("type","audio/x-aiff");
audObj.setAttribute("data","media/aif_sample.aif");

audParam = document.createElement("param");
audParam.setAttribute("name","AutoStart");
audParam.setAttribute("value","false");
audObj.appendChild(audParam);

document.body.appendChild(audObj);

document.getElementById("playButton").onclick = function() {
audObj.Play();
//document.getElementById("objmedia").Play();
}
}
If I change AutoStart to 'true' then the audio starts playing so this
implies that the sound gets load correctly. Is there a way to get
playing to start with a mouse click?

Andrew Poulos
Jul 23 '05 #1
6 4016
On Wed, 22 Dec 2004 10:36:55 +1100, Andrew Poulos wrote:
document.getElementById("playButton").onclick = function() {
audObj.Play();


Try the lowercase version (untested)..

audObj.play();

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #2
Andrew Thompson wrote:
On Wed, 22 Dec 2004 10:36:55 +1100, Andrew Poulos wrote:

document.getElementById("playButton").onclick = function() {
audObj.Play();

Try the lowercase version (untested)..

audObj.play();


Tried it and various other words (start, DoPlay, run,...) no joy.

Andrew Poulos
Jul 23 '05 #3
On Wed, 22 Dec 2004 11:30:51 +1100, Andrew Poulos <ap*****@hotmail.com>
wrote:

[snip]
Tried it and various other words (start, DoPlay, run,...) no joy.


I'd expect Mozilla to only expose the standard properties of an OBJECT
element unless perhaps a plug-in was involved, though I could be wrong.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4
Michael Winter wrote:
On Wed, 22 Dec 2004 11:30:51 +1100, Andrew Poulos <ap*****@hotmail.com>
wrote:

[snip]
Tried it and various other words (start, DoPlay, run,...) no joy.

I'd expect Mozilla to only expose the standard properties of an OBJECT
element unless perhaps a plug-in was involved, though I could be wrong.

Mike

I was kind of afraid of that.

Instead of trying to call an non-existent Play property, I could delete
the child and then create a new OBJECT element with AutoStart set to
true. As the sound file has already been downloaded it should be in the
cache and therefore start playing almost immediately.

Is this an ok way to go?

Andrew Poulos
Jul 23 '05 #5


Andrew Poulos wrote:
As a follow on to the 'fun' I had with IE I'm now trying to play sounds
using an Object tag (no Embed) in MZ. Sadly whenever 'playButton' gets
clicked MZ says that "audObj.Play is not a function":

window.onload = function() {
var audObj = document.createElement("object");
audObj.setAttribute("id", "objmedia");
audObj.setAttribute("type","audio/x-aiff");
audObj.setAttribute("data","media/aif_sample.aif");

audParam = document.createElement("param");
audParam.setAttribute("name","AutoStart");
audParam.setAttribute("value","false");
audObj.appendChild(audParam);

document.body.appendChild(audObj);

document.getElementById("playButton").onclick = function() {
audObj.Play();
//document.getElementById("objmedia").Play();
}
}
If I change AutoStart to 'true' then the audio starts playing so this
implies that the sound gets load correctly. Is there a way to get
playing to start with a mouse click?


A plugin is going to play the audio file, not the browser itself. And if
you want to script that plugin then it needs to expose an API to the
script. Thus whether there is any method and whether it is called 'Play'
depends on the plugin registered with Mozilla for that MIME type
audio/x-aiff. Unless you know your customers have a certain plugin
installed with Mozilla and you find the documention of that plugin and
whether and what kind of method it exposes you can't build that stuff
reliably, it might indeed be more successful to create and insert an
object or embed with autostart being true whenever you want a sound to
be played. Of course even then there needs to be a plugin installed with
Mozilla to handle that MIME type thus if you want Mozilla users on
different platforms to be able to hear that sound then you need to do
some research on what sound format is well supported on different platforms.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #6
Martin Honnen wrote:


Andrew Poulos wrote:
As a follow on to the 'fun' I had with IE I'm now trying to play
sounds using an Object tag (no Embed) in MZ. Sadly whenever
'playButton' gets clicked MZ says that "audObj.Play is not a function":

window.onload = function() {
var audObj = document.createElement("object");
audObj.setAttribute("id", "objmedia");
audObj.setAttribute("type","audio/x-aiff");
audObj.setAttribute("data","media/aif_sample.aif");
audParam = document.createElement("param");
audParam.setAttribute("name","AutoStart");
audParam.setAttribute("value","false");
audObj.appendChild(audParam);
document.body.appendChild(audObj);
document.getElementById("playButton").onclick = function() {
audObj.Play();
//document.getElementById("objmedia").Play();
}
}

If I change AutoStart to 'true' then the audio starts playing so this
implies that the sound gets load correctly. Is there a way to get
playing to start with a mouse click?

A plugin is going to play the audio file, not the browser itself. And if
you want to script that plugin then it needs to expose an API to the
script. Thus whether there is any method and whether it is called 'Play'
depends on the plugin registered with Mozilla for that MIME type
audio/x-aiff. Unless you know your customers have a certain plugin
installed with Mozilla and you find the documention of that plugin and
whether and what kind of method it exposes you can't build that stuff
reliably, it might indeed be more successful to create and insert an
object or embed with autostart being true whenever you want a sound to
be played. Of course even then there needs to be a plugin installed with
Mozilla to handle that MIME type thus if you want Mozilla users on
different platforms to be able to hear that sound then you need to do
some research on what sound format is well supported on different
platforms.


Thanks for the reply. I did some research, if you could call it that, by
googling about the internet and a number of things surprised me:
- most of the code samples are more than 5 years old
- there is no clear, standards compliant way to play sounds. Many big
company sites use an EMBED tag which is non-standard. Even Microsoft
documents a variety of ways to play sounds on Windows [yet Michael
Winter pointed out that the TYPE attribute appears not to be able to
actually be set.]
- Mozilla doesn't have a solution
- I'm tempted to put all sounds into a Flash file and then most of the
"issues" disappear, except that Flash is proprietary.
- I still have to "solve" it for a few other audio formats (and then I
have to look at video)

I wrongly imagined that these sorts of problems had been "solved" years ago.

Andrew Poulos
Jul 23 '05 #7

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

Similar topics

5
by: minchu | last post by:
Hello, I want an image and sound(any format) to load and play simultaneously in my HTML or the sound should play only after the image is loaded. Is this possible?. Pls let me know how. ...
0
by: MLH | last post by:
Edit, Insert Object & choose Wave Object, the following OLE object thing gets inserted onto the form... Microsoft Sound Recorder Version 5.1 (Build 2600.xpsp2.030422-1633: Service Pack 1)...
1
by: Lam | last post by:
how can I play sound file in a .aspx page written in C#? I try to use the code like the following. But whenI call the play function play("sound.wav", this.SND_ASYNC) my computer give out "be"...
3
by: Jared | last post by:
I'm using the first code sample below to play WAV files stored as embedded resources. For some reason I *occasionally* get scratching and crackling. I'm using a couple WAVs that ship with...
9
by: Morris Neuman | last post by:
Im working with VS 2005 and trying to use a Hyperlink field in a datagrid to play a wave file that is not located in the website folders but is in a plain folder on the same machine, windows 2003...
3
by: illmagination | last post by:
Hi, I recently received a task to have a .wav file play only once when home page is 1st loaded and only play again when the user re-visits the page by opening a new browser. I am using...
26
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...
9
by: =?Utf-8?B?anVhbg==?= | last post by:
How can I do to start a thread. I tried everything... but it had no work. Any solution? It is a Sub working with a Timer control. I want to do two tasks at the same time (more or less for a...
8
by: raylopez99 | last post by:
I have the latest version of Visual Studio 2008 Professional, which allows you to create resource files (this is the .resx file, no?), unlike the Express version, which does not. I am trying to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.