Add option to stop player.
This commit is contained in:
parent
dcc2391094
commit
60361b02ae
1 changed files with 9 additions and 0 deletions
|
@ -19,6 +19,10 @@ defmodule MIDITools.Player do
|
|||
GenServer.call(__MODULE__, {:set_repeat, repeat})
|
||||
end
|
||||
|
||||
def stop_playing do
|
||||
GenServer.call(__MODULE__, :stop_playing)
|
||||
end
|
||||
|
||||
# Server callbacks
|
||||
|
||||
@impl true
|
||||
|
@ -57,6 +61,11 @@ defmodule MIDITools.Player do
|
|||
{:reply, :ok, %{state | repeat: repeat}}
|
||||
end
|
||||
|
||||
def handle_call(:stop_playing, _from, %{timer: timer} = state) do
|
||||
Process.cancel_timer(timer, info: false)
|
||||
{:reply, :ok, %{state | timer: nil}}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info(
|
||||
:play,
|
||||
|
|
Loading…
Reference in a new issue