Skip to content

Commit

Permalink
Merge pull request #121 from membraneframework/fix/docs-change-playba…
Browse files Browse the repository at this point in the history
…ck-state-ref

Fix change_playback_state/2 reference.
  • Loading branch information
bblaszkow06 authored Nov 14, 2018
2 parents 982efeb + af91383 commit fc84524
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 3 additions & 1 deletion lib/membrane/core/playback.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Membrane.Core.Playback do
This module defines available playback states and struct that is held
internally by every module having playback state.
There are three playback states: :stopped, :prepared and :playing.
There are three playback states: `:stopped`, `:prepared` and `:playing`.
"""
use Bunch.Access

Expand All @@ -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
23 changes: 16 additions & 7 deletions lib/membrane/core/playback_requestor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,39 @@ defmodule Membrane.Core.PlaybackRequestor do
defmacro __using__(_args) do
quote location: :keep do
@behaviour unquote(__MODULE__)
require Membrane.Core.Playback

@doc """
Alias for `change_playback_state(pid, :playing)`.
See `c:#{__MODULE__}.change_playback_state/2`.
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 """
Alias for `change_playback_state(pid, :prepared)`.
See `c:#{__MODULE__}.change_playback_state/2`.
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 """
Alias for `change_playback_state(pid, :stopped)`.
See `c:#{__MODULE__}.change_playback_state/2`.
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 fc84524

Please sign in to comment.