Fade out music

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

Fade out music

Post by emeck »

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?
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
User avatar
emeck
Posts: 169
Joined: Fri Apr 03, 2015 3:17 pm

Re: Fade out music

Post by emeck »

Forgot to mention this is with Designer 4 and HW 6.1 on MorphOS 3.9
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Fade out music

Post by airsoftsoftwair »

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: 169
Joined: Fri Apr 03, 2015 3:17 pm

Re: Fade out music

Post by emeck »

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)
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
Post Reply