Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pause/resume, paused channel queries and music time functions #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/general.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,37 @@
(defun volume-music (music-volume)
"Adjust the volume of the music. Volume ranges from 0 to 128. The return value is an integer that usually represents the previous volume setting. Passing -1 as the music volume does not change the volume but instead returns the current volume setting"
(mix-volume-music music-volume))

(defun pause (&optional (channel -1))
"Pause channel, or all playing channels if -1 is passed in. You may still halt a paused channel"
(mix-pause channel))

(defun resume (&optional (channel -1))
"Unpause channel, or all playing and paused channels if -1 is passed in"
(mix-resume channel))

(defun paused (channel)
"Tells you if channel is paused, or not. Channel -1 returns the number of paused threads"
(if (= -1 channel)
(get-num-paused-channels)
(/= 0 (mix-paused channel))))

(defun get-num-paused-channels ()
"Tells you the number of paused channels"
(mix-paused -1))

(defun pause-music ()
"Pause the music playback. You may halt paused music"
(mix-pause-music))

(defun resume-music ()
"Unpause the music. This is safe to use on halted, paused, and already playing music"
(mix-resume-music))

(defun rewind-music ()
"Rewind the music to the start. This is safe to use on halted, paused, and already playing music. It is not useful to rewind the music immediately after starting playback, because it starts at the beggining by default"
(mix-rewind-music))

(defun set-music-position (position)
"Set the position of currently playing music. It is highly recommended to read https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_65.html"
(check-rc (mix-set-music-position (float position 1d0))))
10 changes: 9 additions & 1 deletion src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@
#:free-music
#:play-music
#:halt-music
#:volume-music))
#:volume-music
#:pause
#:resume
#:paused
#:get-num-paused-channels
#:pause-music
#:resume-music
#:rewind-music
#:set-music-position))

(in-package :sdl2-mixer)

Expand Down