[Home]AlexChurchill/TickerSoundJavaScript

ec2-54-159-186-146.compute-1.amazonaws.com | ToothyWiki | AlexChurchill | RecentChanges | Login | Webcomic

AlexChurchill uses the ToothyWikiInternals/RSS ticker.  He has this code in the "Custom JavaScript" box to play a sound effect:

hooks.cancelled = false;
// new item in feed
hooks.onNewItem = function() 
{
 hooks.cancelled = false;
 // code to alert user to a new change goes here
 if(!document.getElementById("alexsfx"))
 {
  var newelement = document.createElement("embed");
  newelement.setAttribute("id","alexsfx");
  newelement.setAttribute("hidden","true");
  newelement.setAttribute("autostart","false");
  newelement.setAttribute("loop","false");
  newelement.setAttribute("src","file:////d|/Applications/Windows NT/Pinball/SOUND8.WAV"); 
  // that URL format won't work with all audio plugins. try file://d:/Applications/... too.
  document.body.appendChild(newelement);
 }
 mysound = document.getElementById("alexsfx");
 // player may not be ready yet. I guess I'll have to wait half a sec for my notification
 setTimeout("if(!hooks.cancelled){mysound.play();}",500);
};

// user looked at new item
hooks.onCancelNewItem = function() 
{
 // stop doing whatever you did to alert user
  hooks.cancelled = true; 
};


CH tried this, but it produced an error. It's in the sound-handling code, somewhere. He changed only the name alexsfx in all location, and the file location. It produces an error: "Line 1, Char 22. Object doesn't support this property or method".
Hmm, that's a pity. I saw that error quite a bit when writing (debugging) the code above, but it's working for me at the moment. IIRC you're on IE6 like me, so I fear it'll need debugging in the usual way. Copy the function out to a local HTML document and tie it to a button. Then try to establish what the "object" which is complaining is for starters, I guess... --AlexChurchill
One possibility is that the script doesn't have permission to access the sound file. What are your security permissions, Alex? CH? - MoonShadow
It certainly appears that it is the playing of the file that is the problem. I'll examine my settings (presumably options/security on IE?) --CH
A web-page shouldn't be able to run locally held media.  That's a big potential hole.  Obvious question would be, are you running the ticker direct from toothycat, or from a local copy?  A local copy would have access to local sound files.  --Vitenka
I'm running a remote copy. Would a remote copy have access to any remote file, or just ones in it's own remit? As in, can I host the sound on my srcf space and have it findable by the ticker at toothycat?
Depends on your browser.  Most ad-blockers / popup blockers will prevent it, but raw IE will allow it.  --Vitenka

From MS's POV, it's only a security hole if there's a way for the script to send the local data back or to run an executable with arbitrary parameters; it can display it to the user all it likes. Try embedding an IFRAME pointing to c:\ in a remote HTML page, for instance. Whether the script can get at local data (and is therefore disabled) would depend on the plugin. Alex can run it, and so can I - but for me, the above URL syntax doesn't work; something like "file://d:/Applications?/Windows? NT/Pinball?/SOUND8.WAV" works. I found that if I made the plugin visible and right-clicked on it it told me what the problem was. Oh, and you have to remember that the plugin only gets added once in the above code, so if you change the code you have to refresh the ticker after you save the settings.. - MoonShadow
Hmph. It's now pointing at my srcf location, I've set hidden to false and refreshed. However, I still get the error, and I can't see the control.

Odd. No ideas. Works here ^^; - MoonShadow
Have given up and gone back to a tasteful blue background.

ec2-54-159-186-146.compute-1.amazonaws.com | ToothyWiki | AlexChurchill | RecentChanges | Login | Webcomic
Edit this page | View other revisions | Recently used referrers
Last edited April 21, 2004 4:06 pm (viewing revision 15, which is the newest) (diff)
Search: