Issues with loading sound to UIWebView using JavaScript

Discussion in 'iOS Programming' started by Danneman101, Jan 7, 2009.

  1. Danneman101 macrumors 6502

    Aug 14, 2008
    Ive got a UIWebView that loads a local html-page, which in turn should play a wav-file also located locally (in the resource-folder of the project).

    Anyway, two methods almost works:

    1. Simple href-call
    <a href="test.wav">Play Sound</a>
    Problem with this method is that it loads the sound in Quicktime, but when finished (or clicking "Done" in QT), it doesnt return to the original page but to a blank one. Ive tried target="self" in the href-tag, but that doesnt seem to work...

    2. Using javascript
    function EvalSound(soundobj) {
    	var thissound= eval("document."+soundobj);
    <embed src="test.wav" autostart=false width=0 height=0 name="sound1"
    <input type="button" value="Play Sound" onClick="EvalSound('sound1')">
    There are two problems with this approach:

    a. The sound doesnt restart, but continiues playing from where I last cut it short. Is there a "restart"-attribute to the <embed>-tag?

    b. [ solved ]There is an icon displayed on top of the button of an overcrossed speaker, indicating that there is no sound available. This is from the <embed>-tag. When pressing the form-button, however, it does work. Can this icon be removed, since its missleading? For instance, is there an "invisible"-property in <embed>?

    [*edit ]

    Solution to b.
    <embed src="test.wav" autostart="false" controls="SmallConsole" width="100" height="100" hidden="true" name="sound1" enablejavascript="true" loop="false">

Share This Page