module Mpv.Interpreter.VideoPlayer where import Polysemy.Conc (ChanConsumer, interpretAtomic) import Mpv.Data.AudioId (AudioId (AudioId)) import qualified Mpv.Data.Command as Command import Mpv.Data.Command (Command) import Mpv.Data.MpvError (MpvError) import Mpv.Data.MpvEvent (MpvEvent) import Mpv.Data.MpvProcessConfig (MpvProcessConfig) import qualified Mpv.Data.Property as Property import Mpv.Data.SubtitleId (SubtitleId (SubtitleId)) import qualified Mpv.Effect.Mpv as Mpv import Mpv.Effect.Mpv (Mpv) import Mpv.Effect.MpvServer (MpvServer) import qualified Mpv.Effect.VideoPlayer as VideoPlayer import Mpv.Effect.VideoPlayer (VideoPlayer) import Mpv.Interpreter.MpvServer (interpretMpvClient, withMpvServer) import Mpv.Mpv (addAudioDelay, addSubDelay, adjustVolumeBy, info, togglePlaybackState) import Mpv.Track (audioTracks, subtitles) interpretVideoPlayerMpvAtomic :: ∀ meta r . Members [Mpv !! MpvError, AtomicState (Maybe meta), Race] r => InterpreterFor (VideoPlayer meta !! MpvError) r interpretVideoPlayerMpvAtomic :: forall meta (r :: [(* -> *) -> * -> *]). Members '[Mpv !! MpvError, AtomicState (Maybe meta), Race] r => InterpreterFor (VideoPlayer meta !! MpvError) r interpretVideoPlayerMpvAtomic = (forall x (r0 :: [(* -> *) -> * -> *]). VideoPlayer meta (Sem r0) x -> Sem (Stop MpvError : r) x) -> InterpreterFor (Resumable MpvError (VideoPlayer meta)) r forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). FirstOrder eff "interpretResumable" => (forall x (r0 :: [(* -> *) -> * -> *]). eff (Sem r0) x -> Sem (Stop err : r) x) -> InterpreterFor (Resumable err eff) r interpretResumable \case VideoPlayer meta (Sem r0) x VideoPlayer.Current -> Sem (Stop MpvError : r) x forall s (r :: [(* -> *) -> * -> *]). Member (AtomicState s) r => Sem r s atomicGet VideoPlayer.Load meta meta Path Abs File file -> do Sem (Stop MpvError : r) LoadResponse -> Sem (Stop MpvError : r) () forall (f :: * -> *) a. Functor f => f a -> f () void (Sem (Stop MpvError : r) LoadResponse -> Sem (Stop MpvError : r) ()) -> Sem (Stop MpvError : r) LoadResponse -> Sem (Stop MpvError : r) () forall a b. (a -> b) -> a -> b $ Sem (Mpv : Stop MpvError : r) LoadResponse -> Sem (Stop MpvError : r) LoadResponse forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Command LoadResponse -> Sem (Mpv : Stop MpvError : r) LoadResponse forall (r :: [(* -> *) -> * -> *]) a. Member Mpv r => Command a -> Sem r a Mpv.command (Path Abs File -> Maybe LoadOption -> Command LoadResponse Command.Load Path Abs File file Maybe LoadOption forall a. Maybe a Nothing)) Maybe meta -> Sem (Stop MpvError : r) () forall s (r :: [(* -> *) -> * -> *]). Member (AtomicState s) r => s -> Sem r () atomicPut (meta -> Maybe meta forall a. a -> Maybe a Just meta meta) VideoPlayer meta (Sem r0) x VideoPlayer.Pause -> Sem (Mpv : Stop MpvError : r) PlaybackState -> Sem (Stop MpvError : r) PlaybackState forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop Sem (Mpv : Stop MpvError : r) PlaybackState forall (r :: [(* -> *) -> * -> *]). Member Mpv r => Sem r PlaybackState togglePlaybackState VideoPlayer meta (Sem r0) x VideoPlayer.Stop -> Sem (Stop MpvError : r) EmptyResponse -> Sem (Stop MpvError : r) () forall (f :: * -> *) a. Functor f => f a -> f () void (Sem (Mpv : Stop MpvError : r) EmptyResponse -> Sem (Stop MpvError : r) EmptyResponse forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Command EmptyResponse -> Sem (Mpv : Stop MpvError : r) EmptyResponse forall (r :: [(* -> *) -> * -> *]) a. Member Mpv r => Command a -> Sem r a Mpv.command Command EmptyResponse Command.Stop)) VideoPlayer.Seek Double pos SeekFlags flags -> Sem (Stop MpvError : r) EmptyResponse -> Sem (Stop MpvError : r) () forall (f :: * -> *) a. Functor f => f a -> f () void (Sem (Mpv : Stop MpvError : r) EmptyResponse -> Sem (Stop MpvError : r) EmptyResponse forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Command EmptyResponse -> Sem (Mpv : Stop MpvError : r) EmptyResponse forall (r :: [(* -> *) -> * -> *]) a. Member Mpv r => Command a -> Sem r a Mpv.command (Double -> SeekFlags -> Command EmptyResponse Command.Seek Double pos SeekFlags flags))) VideoPlayer meta (Sem r0) x VideoPlayer.Info -> Sem (Mpv : Stop MpvError : r) MpvInfo -> Sem (Stop MpvError : r) MpvInfo forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop Sem (Mpv : Stop MpvError : r) MpvInfo forall (r :: [(* -> *) -> * -> *]). Member Mpv r => Sem r MpvInfo info VideoPlayer meta (Sem r0) x VideoPlayer.Subtitles -> Sem (Mpv : Stop MpvError : r) Subtitles -> Sem (Stop MpvError : r) Subtitles forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop Sem (Mpv : Stop MpvError : r) Subtitles forall (r :: [(* -> *) -> * -> *]). Member Mpv r => Sem r Subtitles subtitles VideoPlayer.SetSubtitle (SubtitleId Int id') -> Sem (Mpv : Stop MpvError : r) () -> Sem (Stop MpvError : r) () forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Text -> Text -> Sem (Mpv : Stop MpvError : r) () forall (r :: [(* -> *) -> * -> *]). MemberWithError Mpv r => Text -> Text -> Sem r () Mpv.setOption Text "sub" (Int -> Text forall b a. (Show a, IsString b) => a -> b show Int id')) VideoPlayer meta (Sem r0) x VideoPlayer.SubFps -> Sem (Mpv : Stop MpvError : r) SubFps -> Sem (Stop MpvError : r) SubFps forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property SubFps -> Sem (Mpv : Stop MpvError : r) SubFps forall (r :: [(* -> *) -> * -> *]) v. MemberWithError Mpv r => Property v -> Sem r v Mpv.prop Property SubFps Property.SubFps) VideoPlayer.SetSubFps SubFps fps -> Sem (Mpv : Stop MpvError : r) () -> Sem (Stop MpvError : r) () forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property SubFps -> SubFps -> Sem (Mpv : Stop MpvError : r) () forall (r :: [(* -> *) -> * -> *]) v. (MemberWithError Mpv r, Show v) => Property v -> v -> Sem r () Mpv.setProp Property SubFps Property.SubFps SubFps fps) VideoPlayer meta (Sem r0) x VideoPlayer.SubDelay -> Sem (Mpv : Stop MpvError : r) SubDelay -> Sem (Stop MpvError : r) SubDelay forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property SubDelay -> Sem (Mpv : Stop MpvError : r) SubDelay forall (r :: [(* -> *) -> * -> *]) v. MemberWithError Mpv r => Property v -> Sem r v Mpv.prop Property SubDelay Property.SubDelay) VideoPlayer.SetSubDelay SubDelay delay -> Sem (Mpv : Stop MpvError : r) () -> Sem (Stop MpvError : r) () forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property SubDelay -> SubDelay -> Sem (Mpv : Stop MpvError : r) () forall (r :: [(* -> *) -> * -> *]) v. (MemberWithError Mpv r, Show v) => Property v -> v -> Sem r () Mpv.setProp Property SubDelay Property.SubDelay SubDelay delay) VideoPlayer.AddSubDelay SubDelay delta -> Sem (Mpv : Stop MpvError : r) SubDelay -> Sem (Stop MpvError : r) SubDelay forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (SubDelay -> Sem (Mpv : Stop MpvError : r) SubDelay forall (r :: [(* -> *) -> * -> *]). Member Mpv r => SubDelay -> Sem r SubDelay addSubDelay SubDelay delta) VideoPlayer meta (Sem r0) x VideoPlayer.Audios -> Sem (Mpv : Stop MpvError : r) AudioTracks -> Sem (Stop MpvError : r) AudioTracks forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop Sem (Mpv : Stop MpvError : r) AudioTracks forall (r :: [(* -> *) -> * -> *]). Member Mpv r => Sem r AudioTracks audioTracks VideoPlayer.SetAudio (AudioId Int id') -> Sem (Mpv : Stop MpvError : r) () -> Sem (Stop MpvError : r) () forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Text -> Text -> Sem (Mpv : Stop MpvError : r) () forall (r :: [(* -> *) -> * -> *]). MemberWithError Mpv r => Text -> Text -> Sem r () Mpv.setOption Text "audio" (Int -> Text forall b a. (Show a, IsString b) => a -> b show Int id')) VideoPlayer meta (Sem r0) x VideoPlayer.AudioDelay -> Sem (Mpv : Stop MpvError : r) AudioDelay -> Sem (Stop MpvError : r) AudioDelay forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property AudioDelay -> Sem (Mpv : Stop MpvError : r) AudioDelay forall (r :: [(* -> *) -> * -> *]) v. MemberWithError Mpv r => Property v -> Sem r v Mpv.prop Property AudioDelay Property.AudioDelay) VideoPlayer.SetAudioDelay AudioDelay delay -> Sem (Mpv : Stop MpvError : r) () -> Sem (Stop MpvError : r) () forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property AudioDelay -> AudioDelay -> Sem (Mpv : Stop MpvError : r) () forall (r :: [(* -> *) -> * -> *]) v. (MemberWithError Mpv r, Show v) => Property v -> v -> Sem r () Mpv.setProp Property AudioDelay Property.AudioDelay AudioDelay delay) VideoPlayer.AddAudioDelay AudioDelay delta -> Sem (Mpv : Stop MpvError : r) AudioDelay -> Sem (Stop MpvError : r) AudioDelay forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (AudioDelay -> Sem (Mpv : Stop MpvError : r) AudioDelay forall (r :: [(* -> *) -> * -> *]). Member Mpv r => AudioDelay -> Sem r AudioDelay addAudioDelay AudioDelay delta) VideoPlayer meta (Sem r0) x VideoPlayer.Volume -> Sem (Mpv : Stop MpvError : r) Volume -> Sem (Stop MpvError : r) Volume forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property Volume -> Sem (Mpv : Stop MpvError : r) Volume forall (r :: [(* -> *) -> * -> *]) v. MemberWithError Mpv r => Property v -> Sem r v Mpv.prop Property Volume Property.Volume) VideoPlayer.SetVolume Volume value -> Sem (Mpv : Stop MpvError : r) () -> Sem (Stop MpvError : r) () forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property Volume -> Volume -> Sem (Mpv : Stop MpvError : r) () forall (r :: [(* -> *) -> * -> *]) v. (MemberWithError Mpv r, Show v) => Property v -> v -> Sem r () Mpv.setProp Property Volume Property.Volume Volume value) VideoPlayer.AdjustVolumeBy Volume delta -> Sem (Mpv : Stop MpvError : r) Volume -> Sem (Stop MpvError : r) Volume forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Volume -> Sem (Mpv : Stop MpvError : r) Volume forall (r :: [(* -> *) -> * -> *]). Member Mpv r => Volume -> Sem r Volume adjustVolumeBy Volume delta) VideoPlayer meta (Sem r0) x VideoPlayer.Duration -> Sem (Mpv : Stop MpvError : r) VideoDuration -> Sem (Stop MpvError : r) VideoDuration forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property VideoDuration -> Sem (Mpv : Stop MpvError : r) VideoDuration forall (r :: [(* -> *) -> * -> *]) v. MemberWithError Mpv r => Property v -> Sem r v Mpv.prop Property VideoDuration Property.Duration) VideoPlayer meta (Sem r0) x VideoPlayer.Progress -> Sem (Mpv : Stop MpvError : r) VideoProgress -> Sem (Stop MpvError : r) VideoProgress forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property VideoProgress -> Sem (Mpv : Stop MpvError : r) VideoProgress forall (r :: [(* -> *) -> * -> *]) v. MemberWithError Mpv r => Property v -> Sem r v Mpv.prop Property VideoProgress Property.PercentPos) VideoPlayer meta (Sem r0) x VideoPlayer.Expired -> Sem (Mpv : Stop MpvError : r) VideoExpired -> Sem (Stop MpvError : r) VideoExpired forall err (eff :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]). Members '[Resumable err eff, Stop err] r => InterpreterFor eff r restop (Property VideoExpired -> Sem (Mpv : Stop MpvError : r) VideoExpired forall (r :: [(* -> *) -> * -> *]) v. MemberWithError Mpv r => Property v -> Sem r v Mpv.prop Property VideoExpired Property.TimePos) interpretVideoPlayer :: ∀ meta token r . Members [MpvServer Command !! MpvError, EventConsumer token MpvEvent, Log, Resource, Async, Race, Embed IO] r => InterpretersFor [VideoPlayer meta !! MpvError, Mpv !! MpvError] r interpretVideoPlayer :: forall meta token (r :: [(* -> *) -> * -> *]). Members '[MpvServer Command !! MpvError, EventConsumer token MpvEvent, Log, Resource, Async, Race, Embed IO] r => InterpretersFor '[VideoPlayer meta !! MpvError, Mpv !! MpvError] r interpretVideoPlayer = Maybe meta -> InterpreterFor (AtomicState (Maybe meta)) r forall a (r :: [(* -> *) -> * -> *]). Member (Embed IO) r => a -> InterpreterFor (AtomicState a) r interpretAtomic Maybe meta forall a. Maybe a Nothing (Sem (AtomicState (Maybe meta) : r) a -> Sem r a) -> (Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : r) a -> Sem (AtomicState (Maybe meta) : r) a) -> Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : r) a -> Sem r a forall b c a. (b -> c) -> (a -> b) -> a -> c . Sem ((Mpv !! MpvError) : AtomicState (Maybe meta) : r) a -> Sem (AtomicState (Maybe meta) : r) a forall token (r :: [(* -> *) -> * -> *]). Members '[MpvServer Command !! MpvError, EventConsumer token MpvEvent, Log, Resource, Async, Race] r => InterpreterFor (Mpv !! MpvError) r interpretMpvClient (Sem ((Mpv !! MpvError) : AtomicState (Maybe meta) : r) a -> Sem (AtomicState (Maybe meta) : r) a) -> (Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : r) a -> Sem ((Mpv !! MpvError) : AtomicState (Maybe meta) : r) a) -> Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : r) a -> Sem (AtomicState (Maybe meta) : r) a forall b c a. (b -> c) -> (a -> b) -> a -> c . Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : AtomicState (Maybe meta) : r) a -> Sem ((Mpv !! MpvError) : AtomicState (Maybe meta) : r) a forall meta (r :: [(* -> *) -> * -> *]). Members '[Mpv !! MpvError, AtomicState (Maybe meta), Race] r => InterpreterFor (VideoPlayer meta !! MpvError) r interpretVideoPlayerMpvAtomic (Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : AtomicState (Maybe meta) : r) a -> Sem ((Mpv !! MpvError) : AtomicState (Maybe meta) : r) a) -> (Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : r) a -> Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : AtomicState (Maybe meta) : r) a) -> Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : r) a -> Sem ((Mpv !! MpvError) : AtomicState (Maybe meta) : r) a forall b c a. (b -> c) -> (a -> b) -> a -> c . Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : r) a -> Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : AtomicState (Maybe meta) : r) a forall (e3 :: (* -> *) -> * -> *) (e1 :: (* -> *) -> * -> *) (e2 :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]) a. Sem (e1 : e2 : r) a -> Sem (e1 : e2 : e3 : r) a raise2Under interpretVideoPlayerServer :: Members [Reader MpvProcessConfig, Log, Resource, Async, Race, Time t d, Embed IO, Final IO] r => InterpretersFor [VideoPlayer meta !! MpvError, Mpv !! MpvError, ChanConsumer MpvEvent] r interpretVideoPlayerServer :: forall t d (r :: [(* -> *) -> * -> *]) meta. Members '[Reader MpvProcessConfig, Log, Resource, Async, Race, Time t d, Embed IO, Final IO] r => InterpretersFor '[VideoPlayer meta !! MpvError, Mpv !! MpvError, ChanConsumer MpvEvent] r interpretVideoPlayerServer = Sem ((MpvServer Command !! MpvError) : ChanConsumer MpvEvent : r) a -> Sem r a forall t d (r :: [(* -> *) -> * -> *]). Members '[Reader MpvProcessConfig, Time t d, Log, Resource, Race, Async, Embed IO, Final IO] r => InterpretersFor '[MpvServer Command !! MpvError, ChanConsumer MpvEvent] r withMpvServer (Sem ((MpvServer Command !! MpvError) : ChanConsumer MpvEvent : r) a -> Sem r a) -> (Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : ChanConsumer MpvEvent : r) a -> Sem ((MpvServer Command !! MpvError) : ChanConsumer MpvEvent : r) a) -> Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : ChanConsumer MpvEvent : r) a -> Sem r a forall b c a. (b -> c) -> (a -> b) -> a -> c . Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : (MpvServer Command !! MpvError) : ChanConsumer MpvEvent : r) a -> Sem ((MpvServer Command !! MpvError) : ChanConsumer MpvEvent : r) a forall meta token (r :: [(* -> *) -> * -> *]). Members '[MpvServer Command !! MpvError, EventConsumer token MpvEvent, Log, Resource, Async, Race, Embed IO] r => InterpretersFor '[VideoPlayer meta !! MpvError, Mpv !! MpvError] r interpretVideoPlayer (Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : (MpvServer Command !! MpvError) : ChanConsumer MpvEvent : r) a -> Sem ((MpvServer Command !! MpvError) : ChanConsumer MpvEvent : r) a) -> (Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : ChanConsumer MpvEvent : r) a -> Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : (MpvServer Command !! MpvError) : ChanConsumer MpvEvent : r) a) -> Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : ChanConsumer MpvEvent : r) a -> Sem ((MpvServer Command !! MpvError) : ChanConsumer MpvEvent : r) a forall b c a. (b -> c) -> (a -> b) -> a -> c . Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : ChanConsumer MpvEvent : r) a -> Sem (Resumable MpvError (VideoPlayer meta) : (Mpv !! MpvError) : (MpvServer Command !! MpvError) : ChanConsumer MpvEvent : r) a forall (e3 :: (* -> *) -> * -> *) (e1 :: (* -> *) -> * -> *) (e2 :: (* -> *) -> * -> *) (r :: [(* -> *) -> * -> *]) a. Sem (e1 : e2 : r) a -> Sem (e1 : e2 : e3 : r) a raise2Under