sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Sound Effecs in SketchUp (HELP)

    Scheduled Pinned Locked Moved Developers' Forum
    31 Posts 6 Posters 6.0k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dan RathbunD Offline
      Dan Rathbun
      last edited by

      The UI::WebDialog interface is not yet HTML5 compliant. AFAIK

      (You have not filled out your profile, so without knowing what platform you are on, it would be hard to help further.)

      But... you might try playing the sound file by using:
      UI.openURL('C:/path/to/sounds/sound.wav')

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        and if it was IE can't play .wav in audio tags....

        Desktop browser audio codec support
        Desktop Browser Version Codec Support
        Internet Explorer 9.0+ MP3, AAC
        Chrome 6.0+ Ogg Vorbis, MP3, WAV†
        Firefox 3.6+ Ogg Vorbis, WAV
        Safari 5.0+ MP3, AAC, WAV
        Opera 10.0+ Ogg Vorbis, WAV

        how bizarre

        john

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          There is also the sound specific UI.play_sound('C:/path/to/sounds/sound.wav') which you could include in a timer or animation 'block' so more than one sound runs concurrently ?

          TIG

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @dan rathbun said:

            The UI::WebDialog interface is not yet HTML5 compliant. AFAIK

            It's more IE not being compliant. IE10 should be though. But in a Webdialog you might need to force it into the correct document mode with a meta tag.

            <meta http-equiv="X-UA-Compatible" content="IE=edge"/>

            And have an HTML5 header.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • renderizaR Offline
              renderiza
              last edited by

              Tried;
              UI.openURL(‘javascript_with_html5_audio.html')

              With the “UI.openURL” I can activate the HTML5 audio using the javascript code but, this action deselects my UI::WebDialog to open the new "html" and it makes the game unplayable.
              Although with that method all the sounds overlay with each other without any problem. Also since multiple sounds are being called constantly the browser is left with too much opened windows tabs (not good).

              If I then use;
              UI.openURL(‘sound.wav')
              This will also deselect the UI::WebDialog to open the audio player.


              I am trying to figure how to make this work by combining the UI.play_sound with UI.start_timer using this code;

              
              if (params['z'].to_i < 0 ) then
              UI.start_timer(0, false) { UI.play_sound @ball_sound;}
              end ;
              

              I have not achieved what I want, which is too concurrently overlay sounds one on top of each other without it clipping the sound. Although being able to delay or repeat the sound is nice.

              The “animation ‘block’ suggestion…I am not sure how to try that at the moment so I will research a little bit more to see if I can figure it out.

              Thanks everyone for reply...I will keep trying to solve this.

              [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                The Windows Scripting Host can run Js code natively.

                (1) Try making your javascript a standalone "rezballiza_sounds.js" file.

                Then call that .js file with:

                @sounds_path = "C;/path/to/rezballiza/dir"
                @sounds_script = File.join(@sounds_path,"rezballiza_sounds.js")
                UI.openURL(@sounds_script)
                

                (2) Use Ruby's execute system command (the backquote method.)

                either:
                wscript C:/path/to/rezballiza/dir/rezballiza_sounds.js``
                or:
                %x[wscript C:/path/to/rezballiza/dir/rezballiza_sounds.js]

                (In a system command console, type wscript -? to see a popup with wscript command line parameters.)

                On Windows.. using a backquoted (**``**) or %x` delimited execute string, currently there is no way to suppress the momentary display of a command console window.

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • renderizaR Offline
                  renderiza
                  last edited by

                  Dan Rathbun… I followed you in step 1 but step 2 has me lost.

                  The following is another of my tests;

                  <head>
                  <bgsound src="#" id="soundeffect" loop=0 autostart="true" />
                  </head>
                  
                  <script>
                  var soundfile="zap1.wav"
                  
                  function playsound(soundfile){
                  if (document.all && document.getElementById){
                  document.getElementById("soundeffect").src=soundfile
                  }
                  }
                  playsound(soundfile) //to play the sound
                  </script>
                  

                  The result;

                  The sounds work but I get a quick screen freeze every time a sound is played. Maybe 300 KB sound size is too much but not sure. Anyways I will keep trying new stuff untill I stumble with a solution. If anyone is brave enough to give it a shoot please do. The game code is here;

                  Dropbox

                  favicon

                  (www.dropbox.com)

                  Thanks

                  [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                  1 Reply Last reply Reply Quote 0
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    @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'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • renderizaR Offline
                      renderiza
                      last edited by

                      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

                      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                      1 Reply Last reply Reply Quote 0
                      • Dan RathbunD Offline
                        Dan Rathbun
                        last edited by

                        @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.

                        I'm not here much anymore.

                        1 Reply Last reply Reply Quote 0
                        • Dan RathbunD Offline
                          Dan Rathbun
                          last edited by

                          @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

                          I'm not here much anymore.

                          1 Reply Last reply Reply Quote 0
                          • TIGT Offline
                            TIG Moderator
                            last edited by

                            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... 😒

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • renderizaR Offline
                              renderiza
                              last edited by

                              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 error

                              The 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.

                              [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                              1 Reply Last reply Reply Quote 0
                              • tbdT Offline
                                tbd
                                last edited by

                                wonder if http://plugins.ro/labs/suave.htm still works nowadays. as I moved to OSX, anyone wants to try it out ?

                                SketchUp Ruby Consultant | Podium 1.x developer
                                http://plugins.ro

                                1 Reply Last reply Reply Quote 0
                                • Dan RathbunD Offline
                                  Dan Rathbun
                                  last edited by

                                  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'm not here much anymore.

                                  1 Reply Last reply Reply Quote 0
                                  • renderizaR Offline
                                    renderiza
                                    last edited by

                                    @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

                                    [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                                    1 Reply Last reply Reply Quote 0
                                    • Dan RathbunD Offline
                                      Dan Rathbun
                                      last edited by

                                      Well you would need require the js file where Audio IS defined, I would imagine.

                                      I'm not here much anymore.

                                      1 Reply Last reply Reply Quote 0
                                      • TIGT Offline
                                        TIG Moderator
                                        last edited by

                                        OR perhaps something like
                                        snd=document.createElement('audio'); snd.setAttribute('src', 'zap1.wav'); snd.play();
                                        ?

                                        TIG

                                        1 Reply Last reply Reply Quote 0
                                        • D Offline
                                          driven
                                          last edited by

                                          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

                                          learn from the mistakes of others, you may not live long enough to make them all yourself...

                                          1 Reply Last reply Reply Quote 0
                                          • renderizaR Offline
                                            renderiza
                                            last edited by

                                            @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

                                            [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement