Blitz3D+ Command Reference

ResumeChannel channel

Parameters

channel - channel handle previously paused with PauseChannel

Description

Restarts a channel that was paused, from exactly where it stopped.

It is the other half of PauseChannel. Together they are what a pause menu is built from: pause every channel you are tracking when the player opens the menu, resume them all when play continues, and the music carries on mid-bar instead of jumping back to the beginning.

It is a Channel command, so it needs the same handle you paused. Resuming a channel that is already running, or one that has finished, does nothing - which makes it safe to call across a whole list without checking each one first.

It cannot revive a channel you ended with StopChannel. Stopping is final; play the sound again for a fresh channel. That is worth remembering when you are deciding which of the two to use for a temporary silence.

It works for music channels from PlayMusic as well as sound effects.

See also: PauseChannel, StopChannel, ChannelPlaying, PlaySound, PlayMusic.

Example

; ResumeChannel Example
; ---------------------

Graphics 640,480,0,2
SetBuffer BackBuffer()

; A short tone looped endlessly gives us a steady engine hum
snd=LoadSound("media/beep.wav")
LoopSound snd
channel=PlaySound(snd)

paused=0
angle#=0

While Not KeyDown(1)

    ; P pauses the channel (see PauseChannel)
    If KeyHit(25) And paused=0 Then
        PauseChannel channel
        paused=1
    End If

    ; R resumes the paused channel: playback carries on exactly
    ; where PauseChannel froze it - nothing is restarted
    If KeyHit(19) And paused=1 Then
        ResumeChannel channel
        paused=0
    End If

    ; The fan only spins while the engine hum is running
    If paused=0 Then angle=angle+4

    Cls

    Color 100,100,100
    Oval 250,170,140,140,False
    Color 255,255,255
    Line 320,240,320+Cos(angle)*60,240+Sin(angle)*60
    Line 320,240,320-Cos(angle)*60,240-Sin(angle)*60

    If paused Then
        Color 255,180,80
        Text 320,340,"PAUSED - press R for ResumeChannel channel",True
    Else
        Color 80,255,80
        Text 320,340,"RUNNING",True
    End If

    Color 255,255,255
    Text 0,0,"P: pause   R: resume   Esc: exit"

    Flip

Wend

StopChannel channel

End

Index