module Mpv.Data.PlaybackState where

import Polysemy.Time.Json (json)

data PlaybackState =
  Playing
  |
  Paused
  deriving stock (PlaybackState -> PlaybackState -> Bool
(PlaybackState -> PlaybackState -> Bool)
-> (PlaybackState -> PlaybackState -> Bool) -> Eq PlaybackState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PlaybackState -> PlaybackState -> Bool
$c/= :: PlaybackState -> PlaybackState -> Bool
== :: PlaybackState -> PlaybackState -> Bool
$c== :: PlaybackState -> PlaybackState -> Bool
Eq, Int -> PlaybackState -> ShowS
[PlaybackState] -> ShowS
PlaybackState -> String
(Int -> PlaybackState -> ShowS)
-> (PlaybackState -> String)
-> ([PlaybackState] -> ShowS)
-> Show PlaybackState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PlaybackState] -> ShowS
$cshowList :: [PlaybackState] -> ShowS
show :: PlaybackState -> String
$cshow :: PlaybackState -> String
showsPrec :: Int -> PlaybackState -> ShowS
$cshowsPrec :: Int -> PlaybackState -> ShowS
Show, (forall x. PlaybackState -> Rep PlaybackState x)
-> (forall x. Rep PlaybackState x -> PlaybackState)
-> Generic PlaybackState
forall x. Rep PlaybackState x -> PlaybackState
forall x. PlaybackState -> Rep PlaybackState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PlaybackState x -> PlaybackState
$cfrom :: forall x. PlaybackState -> Rep PlaybackState x
Generic)

json ''PlaybackState

fromBool :: Bool -> PlaybackState
fromBool :: Bool -> PlaybackState
fromBool Bool
s =
  if Bool
s then PlaybackState
Paused else PlaybackState
Playing

toBool :: PlaybackState -> Bool
toBool :: PlaybackState -> Bool
toBool = \case
  PlaybackState
Playing -> Bool
False
  PlaybackState
Paused -> Bool
True

toggle :: PlaybackState -> PlaybackState
toggle :: PlaybackState -> PlaybackState
toggle = \case
  PlaybackState
Playing -> PlaybackState
Paused
  PlaybackState
Paused -> PlaybackState
Playing