Sound on and off

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Seville
    Indigo Rose Customer
    • Nov 2004
    • 16

    Sound on and off

    Hi guys, I need some help, my project has ten different pages, each page has a flash file with sound in it, but also my project when starts has background music, this what I would like to happen: When some one opens the project it will show the first page (intro) with the sound (background in this case) but when you click let's say page number three, when page three opens a flash file, I want my background sound to stop playing by itself. When the user is done with page three, he can start the background music if he wants it, then again if he clicks page nine, I want to stop my background music otherwise, I have the background music playing plus the sound of my flash file, you can imagine, it is a mess.
    Any suggestions?
    Seville
  • Brett
    Indigo Rose Staff Member
    • Jan 2000
    • 2001

    #2
    What about putting a Audio.Pause command on the pages with Flash files and then an Audio.Play command on the pages that should have audio. Check out the attached project for a simple illustration.
    Attached Files

    Comment

    • Seville
      Indigo Rose Customer
      • Nov 2004
      • 16

      #3
      Thank you for your help.

      Comment

      • Toosheds
        Indigo Rose Customer
        • Mar 2004
        • 53

        #4
        Similar Question

        I have a one-page project with background music. The page serves basically as a menu to launch an external slide show program, which cannot be integrated into AMS. Each slide show has its own music. Getting the AMS background music to pause when the external program is launched is no problem. What I would like to have happen is for the background music to automatically resume when the external program is exited (and the AMS page is once again on the screen). I tried using Audio.TogglePlay on Enter with a full screen Hotspot, which didn't work correctly for maybe obvious reasons. I'm thinking there must be an if/then script that could help me out. Any ideas?

        Thanks!

        Comment

        • yosik
          Indigo Rose Customer
          • Jun 2002
          • 1858

          #5
          Your way of using a hotspot on the window is one of the ways to go.
          onClick:
          1. Audio.Pause (5)
          2. Hotspot.SetEnabled("Hotspot1", true);
          3. File.Run.......

          When closing your slideshow, you then have your app open with a full window hotspot, so, what you have to add as actions on the onEnter tab of the hotspot is the following:
          1. Audio.Play (5)
          2. Hotspot.SetEnabled("Hotspot1", false);

          Good luck

          Yossi

          Comment

          • TJ_Tigger
            Indigo Rose Customer
            • Sep 2002
            • 3159

            #6
            Another idea is to have a function on the On Timer event that looks for the title of the external window. While the external window is present tell AMS not to play music. Once it disappears, have it start playing the music again.

            Tigg
            TJ-Tigger
            "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
            "Draco dormiens nunquam titillandus."
            Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

            Comment

            • Corey
              Indigo Rose Staff Alumni
              • Aug 2002
              • 9745

              #7
              They're all good ideas. I've had some success with Tigg's method before. :yes

              Comment

              • TJ_Tigger
                Indigo Rose Customer
                • Sep 2002
                • 3159

                #8
                Create a function called ClapOn and another function called ClapOff and then the controlling funciton called TheClapper.
                TJ-Tigger
                "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
                "Draco dormiens nunquam titillandus."
                Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

                Comment

                • Worm
                  Indigo Rose Customer
                  • Jul 2002
                  • 3971

                  #9
                  I'll throw my 2 pennies in.

                  When you launch the external SlideShow Player, use AMS's WaitForReturn option. Something like this.

                  Code:
                  --pause the music
                  Audio.Pause(CHANNEL_USER1)
                  --hide the AMS window
                  Window.Hide(Application.GetWndHandle())
                  --run the slide show, wait for it to end
                  nResult = File.Run("Autoplay\\Docs\\MySlideShow.EXE", "", "", SW_SHOWNORMAL, true)
                  --show the AMS window
                  Window.Show(Application.GetWndHandle())
                  --let the music play
                  Audio.Play(CHANNEL_USER1)

                  Comment

                  • Toosheds
                    Indigo Rose Customer
                    • Mar 2004
                    • 53

                    #10
                    Works!

                    You guys are great! The Hotspot worked from the start, but, after returning from a slide show, the music skipped and stopped - not much, but just enough to irritate. I tried combining Worm and Tiggers solutions, but ran into problems with the Timer because there are 7 different shows. Additionally, the Window.Hide action caused major headaches, making a running app disappear into a previously to me unkown netherland that Task Manager couldn't even see. In any case, I was unable to relaunch another preview until I rebooted. This happened three times before I realized that Worm's solution would probably work as well without the Window commands, as my AMS and the slide shows are all full screen. Voilá! -

                    --pause the music
                    Audio.Pause(CHANNEL_USER1)
                    --run the slide show, wait for it to end
                    nResult = File.Run("Autoplay\\Docs\\MySlideShow.EXE", "", "", SW_SHOWNORMAL, true)
                    --let the music play
                    Audio.Play(CHANNEL_USER1)

                    seems to work great!

                    It is the "nresult =" thing that was new to me. I'll have to research that one.

                    Now if there such a thing as Audio.FadeOut ........

                    Comment

                    • Worm
                      Indigo Rose Customer
                      • Jul 2002
                      • 3971

                      #11
                      Code:
                      nVol = Audio.GetVolume(CHANNEL_USER1)
                      for nCtr = nVol, 0, -1 do
                      	Audio.SetVolume(CHANNEL_USER1, nCtr)
                      	--increase this number to slow down the fade
                      	Application.Sleep(100)
                      end

                      Comment

                      • TJ_Tigger
                        Indigo Rose Customer
                        • Sep 2002
                        • 3159

                        #12
                        Code:
                        --[[
                        Function created to fade out audio in a particular channel
                        	sChannel 		Identify the channel to fade out
                        	nVolumeStep		The level of change between steps, smaller numbers create a smoother fade
                        	nDuration		The amount of time in milliseconds to take for a fadeout
                        ]]
                        function Audio.FadeOut(sChannel, nVolumeStep, nDuration)
                        	nVol = Audio.GetVolume(sChannel);
                        	-- Determine the number of steps required to reduce to 0
                        	nDiv = nVol / nVolumeStep;
                        	-- Use nDiv to determine the sleep time between steps
                        	nSleep = Math.Floor(nDuration / nDiv);
                        	for nCtr = nVol, 0, -nVolumeStep do
                        		Audio.SetVolume(sChannel, nCtr);
                        		Application.Sleep(nSleep);
                        	end
                        	Audio.Pause(sChannel);
                        end
                        
                        Audio.FadeOut(CHANNEL_NARRATION, 3, 5000);
                        Edit: Added Audio.Pause to the function.
                        Last edited by TJ_Tigger; 01-21-2005, 01:16 PM.
                        TJ-Tigger
                        "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
                        "Draco dormiens nunquam titillandus."
                        Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

                        Comment

                        • TJ_Tigger
                          Indigo Rose Customer
                          • Sep 2002
                          • 3159

                          #13
                          Of course, Worm beats me to it. You could create a fade in as well. using the same structure.
                          TJ-Tigger
                          "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
                          "Draco dormiens nunquam titillandus."
                          Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

                          Comment

                          • Worm
                            Indigo Rose Customer
                            • Jul 2002
                            • 3971

                            #14
                            Show off!

                            You rock! :yes :yes

                            Comment

                            • Intrigued
                              Indigo Rose Customer
                              • Dec 2003
                              • 6138

                              #15
                              That's pretty cool TJ_TIGGER!

                              That's a (Code) Keeper for sure!

                              :yes
                              Intrigued

                              Comment

                              Working...
                              X