Sound Effecs in SketchUp (HELP)
-
@unknownuser said:
Dan Rathbun… I followed you in step 1 but step 2 has me lost.
They are NOT sequential steps.
They were separate suggested possible solutions.
Both are Ruby code examples.
The global [`()](http://www.ruby-doc.org/core-1.8.6/Kernel.html#method-i-60) method (name is the backquote character) aka ` %x` delimited string.
Using special delimited strings ( which refers to:)
- Shell Command.
A shell command is a string enclosed in backquotes, or in a general delimited string starting with
%x
. The value of the string is the standard output of running the command represented by the string under the host operating system's standard shell. The execution also sets the$?
variable with the command's exit status.dos-like example:
filter = "*.rb" files =
dir #{filter}files = %x{dir #{filter}}
unix-like example:
filter = "*.rb" files =
ls #{filter}files = %x{ls #{filter}}
-
I don’t know if I am doing something wrong but the 1st option opens adobe dreamweaver.
Dan Rathbun… As much as I will like to say I understand everything, the reality is that I just started the process of learning programming a few weeks ago but I will do my best. Thanks -
@unknownuser said:
I don’t know if I am doing something wrong but the 1st option opens adobe dreamweaver.
UI.openURL
will open the file type with the application that is registered by the system for that file extension.Somehow your system was set to open .js files with Adobe Dreamweaver ?
This should not have been done.
Start Menu > Default Programs > Associate a filetype or protocol with a program
... wait for the list to load (it takes a few minutes.)
Scroll down to .js file, and double click it.
It should be set to "Microsoft (R) Windows Based Script Host" (which is wscript.exe)
If it is set to Adobe Dreamweaver, you should set it back to the default.
-
@unknownuser said:
..., the reality is that I just started the process of learning programming a few weeks ago ...
Get and read this: [doc] Programming Ruby (The "Pick-Axe" Book)
... and the Ruby 1.8.6 Reference Dictionary
-
Another common screw-up is that .jar files [executable Java archives] that should auto-run as if they were an .exe file can get 'taken over' by several compression apps, and therefore they 'open' rather than 'run'
This can break some of my tools that use these file-types to allow image manipulations 'cross-platform' - e.g. ImageTrimmer... -
Here is what appears now;
Script: C:\Program Files (x86)\Google SketchUp 8\Plugins\Resballiza\resballiza_sounds.js
Line: 1
Char: 1
Error: Syntax error
Code: 800A03EA
Source: Microsoft JScript compilation errorThe Javascript file has this code inside;
<script> var snd = new Audio("zap1.wav"); // buffers automatically when created snd.play(); </script>
Maybe I should have other code for it to work.
-
wonder if http://plugins.ro/labs/suave.htm still works nowadays. as I moved to OSX, anyone wants to try it out ?
-
the <script> and </script> tags are HTML tags only for embedding javascript inline inside HTML files.
There are NOT allowed in separate js files.
-
@unknownuser said:
wonder if http://plugins.ro/labs/suave.htm still works nowadays. as I moved to OSX, anyone wants to try it out ?
Well actually I tried it a couple of days ago and didn't get any sounds.
@dan rathbun said:
the <script> and </script> tags are HTML tags only for embedding javascript inline inside HTML files.
There are NOT allowed in separate js files.
I knew that... lol
Now the error says;
Script: C:\Program Files (x86)\Google SketchUp 8\Plugins\Resballiza\resballiza_sounds.js
Line: 3
Char: 1
Error: 'Audio' is undefined
Code: 800A1391
Source: Microsoft JScript runtime error -
Well you would need require the js file where Audio IS defined, I would imagine.
-
OR perhaps something like
snd=document.createElement('audio'); snd.setAttribute('src', 'zap1.wav'); snd.play();
? -
When run from Ruby Console the tests in the WebDialog , except the 'IE' BGSOUND tag work on a mac, obviously only single file, as written, and only with plugin for the java ones.
wwhdlg = UI;;WebDialog.new("wot_works_here", true, "wwh", 1200, 641, 50, 50, true); wwhdlg.set_url "http://www.phon.ucl.ac.uk/home/mark/audio/play.htm" wwhdlg.show_modal wwhdlg.navigation_buttons_enabled=true
john
-
@tig said:
OR perhaps something like
snd=document.createElement('audio'); snd.setAttribute('src', 'zap1.wav'); snd.play();
?Keep getting errors
Error 'document' is undefined
...if I use;
var snd=document.createElement('audio');
var snd.setAttribute('src', 'zap1.wav');
snd.play();it says;
Error: Expected ';'
@driven said:
When run from Ruby Console the tests in the WebDialog , except the 'IE' BGSOUND tag work on a mac, obviously only single file, as written, and only with plugin for the java ones.
wwhdlg = UI;;WebDialog.new("wot_works_here", true, "wwh", 1200, 641, 50, 50, true); > wwhdlg.set_url "http://www.phon.ucl.ac.uk/home/mark/audio/play.htm" > wwhdlg.show_modal > wwhdlg.navigation_buttons_enabled=true
john
This is a nice way of testing what sounds work in UI::WebDialog
-
Perhaps...
var snd=document.createElement('audio'); snd.setAttribute('src', 'zap1.wav'); snd.play();
-
your code works fine when using the .html extension with
<script>
var snd=document.createElement('audio');
snd.setAttribute('src', 'zap1.wav');
snd.play();
</script>But... when using .js extension and trying to open it with "Microsoft (R) Windows Based Script Host" using this code it does't work.
var snd=document.createElement('audio');
snd.setAttribute('src', 'zap1.wav');
snd.play(); -
of course not...
%(#8000BF)[document]
is the HTML DOM object, only valid in browsers. -
In a
UI::WebDialog
for old pre-HTML5 which is what PC SketchUp currently uses...try using an
%(#8000BF)[<embed>]
tag.<EMBED type="audio/x-midi" src="BackInTheSaddle.mid" hidden="true">
see [MSDN: <embed>](http://msdn.microsoft.com/en-us/library/ms535245(v)
And for the various MIME type strings:
-
On Windows there is also a lightweight player in the same folder as the normal Media Player.
It is named "mplayer2.exe"
Also the switch -min or /min seems to work to minimize the interface.
The path on XP:
%(#804000)[%ProgramFiles%/Windows Media Player/mplayer2]
in Ruby that would be:
player_path = File.join(ENV["ProgramFiles"],"/Windows Media Player/mplayer2")
I thot at one time this also was distro'd as an ActiveX control (.ocx file) that could be embedded in webpages ?? (But that may only be MSIE.)
-
@dan rathbun said:
In a
UI::WebDialog
for old pre-HTML5 which is what PC SketchUp currently uses...try using an
%(#8000BF)[<embed>]
tag.Here is how I implemented the <embed> tag;
<script> function playSound(soundfile) { document.getElementById("dummy").innerHTML= "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />"; } playSound('zap1.wav') // I then place this to play the sounds </script> <body> <span id="dummy"></span> //This needs to be in there or it won't work </body>
The results:
This script plays the sound but causes lag in the game and makes it unplayable. The frame rate pauses until the sound is played and then it continues.
This problem didn't happen when using the UI.play_sound or UI.openURL because I asume the UI::WebDialog didn't play any part in handling the sound so it never lagged.
I think the best option would have been UI.play_sound if it never clipped the sound when trying to play more than one sound at a time.
The UI.openURL is the next best thing because it overlays sound perfectly and it doesn't cause lag but the UI::WebDialog loses focus and I can't play the game no more. I even try to put this <BODY ONBLUR="window.focus()"> on the webdialog but it didn't work.
-
@unknownuser said:
Actually, the <embed> method is working great for making a sound if you get hit by a ball or if you grab a live or bonus because I don’t mind the pause to the game in that instance…I actually like it!
The only problem left to resolve is how to produce a sound every time a ball falls without clipping the sound and lag.
Well it doesn't work any good now because I added more bonus and lives items and its just a mess when you grab more than one of does.
Advertisement