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 6 4016
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
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.
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
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/
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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.
...
|
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)...
|
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"...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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,...
| |