Skip to content

Commit

Permalink
Add docs for change_playback_state
Browse files Browse the repository at this point in the history
  • Loading branch information
bblaszkow06 committed Nov 13, 2018
1 parent cf9fcb7 commit af91383
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/membrane/core/playback.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ defmodule Membrane.Core.Playback do
}

@type state_t :: :stopped | :prepared | :playing

defguard is_playback_state(atom) when atom in [:stopped, :prepared, :playing]
end
14 changes: 13 additions & 1 deletion lib/membrane/core/playback_requestor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,39 @@ defmodule Membrane.Core.PlaybackRequestor do
defmacro __using__(_args) do
quote location: :keep do
@behaviour unquote(__MODULE__)
require Membrane.Core.Playback

@doc """
Changes playback state to `:playing`.
An alias for `change_playback_state/2` with proper state.
"""
@spec play(pid) :: :ok
def play(pid), do: change_playback_state(pid, :playing)

@doc """
Changes playback state to `:prepared`.
An alias for `change_playback_state/2` with proper state.
"""
@spec prepare(pid) :: :ok
def prepare(pid), do: change_playback_state(pid, :prepared)

@doc """
Changes playback state to `:stopped`.
An alias for `change_playback_state/2` with proper state.
"""
@spec stop(pid) :: :ok
def stop(pid), do: change_playback_state(pid, :stopped)

@impl unquote(__MODULE__)
def change_playback_state(pid, new_state) do
@doc """
Changes the playback state to the `new_state`.
"""
@spec change_playback_state(pid, Playback.state_t()) :: :ok
def change_playback_state(pid, new_state)
when Membrane.Core.Playback.is_playback_state(new_state) do
alias Membrane.Core.Message
require Message
Message.send(pid, :change_playback_state, new_state)
Expand Down

0 comments on commit af91383

Please sign in to comment.