Fade out music

Anything related to Hollywood Designer goes in here
Post Reply
User avatar
emeck
Posts: 52
Joined: Fri Apr 03, 2015 3:17 pm

Fade out music

Post by emeck » Sun Mar 19, 2017 11:17 pm

Hello,

I have a Designer project with an mp3 as background music, loaded in the first page with id 1. I want to fade out the music in the last page, were I have this loop as code in the page:

Code: Select all

For i=64 To 0 Step -1
    SetVolume(1,i)
Next
but when displaying the last page I get the message "Could not find sample 1!" (or "Could not find music 1!" If SetMusicVolume is used). I tried loadin the mp3 as sample or stream and same result.

What Am I missing?

User avatar
emeck
Posts: 52
Joined: Fri Apr 03, 2015 3:17 pm

Re: Fade out music

Post by emeck » Mon Mar 20, 2017 12:23 am

Forgot to mention this is with Designer 4 and HW 6.1 on MorphOS 3.9

User avatar
airsoftsoftwair
Posts: 2450
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: Fade out music

Post by airsoftsoftwair » Tue Mar 21, 2017 1:13 am

You need to assign an ID for the MP3 in the sound dialog, e.g. "MYMUSIC". Then you can access this music by using the %@MYMUSIC wildcard, e.g. like this:

Code: Select all

For i=64 To 0 Step -1
    SetMusicVolume(%@MYMUSIC,i)
    Wait(5)
Next
Note the Wait() call. If you don't use a short delay, the fade will be so fast that it won't be noticeable and the music will just stop right away.

User avatar
emeck
Posts: 52
Joined: Fri Apr 03, 2015 3:17 pm

Re: Fade out music

Post by emeck » Tue Mar 21, 2017 3:38 pm

airsoftsoftwair wrote:You need to assign an ID for the MP3 in the sound dialog, e.g. "MYMUSIC". Then you can access this music by using the %@MYMUSIC wildcard, e.g. like this:
...
Note the Wait() call. If you don't use a short delay, the fade will be so fast that it won't be noticeable and the music will just stop right away.
Thanks! Working now. Since code executes before the the page or object I had to finish with a last black page with corssfade transition, nice to end videos of a presentation. But music contimues playing until the presentation is closed so just in case I added StopMusic at the end. This is the final code:

Code: Select all

For i  = 64 To 0 Step -1
    SetMusicVolume(%@BMUSIC,i)
    Wait(5)
Next
StopMusic(%@BMUSIC)

Post Reply