{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.MediaSource
(newMediaSource, addSourceBuffer, addSourceBuffer_,
removeSourceBuffer, endOfStream, isTypeSupported, isTypeSupported_,
setLiveSeekableRange, clearLiveSeekableRange, getSourceBuffers,
getActiveSourceBuffers, setDuration, getDuration, getReadyState,
sourceopen, sourceended, sourceclose, MediaSource(..),
gTypeMediaSource)
where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums
newMediaSource :: (MonadDOM m) => m MediaSource
newMediaSource :: forall (m :: * -> *). MonadDOM m => m MediaSource
newMediaSource
= DOM MediaSource -> m MediaSource
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSVal -> MediaSource
MediaSource (JSVal -> MediaSource) -> JSM JSVal -> DOM MediaSource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> JSM JSVal -> () -> JSM JSVal
forall constructor args.
(MakeObject constructor, MakeArgs args) =>
constructor -> args -> JSM JSVal
new (String -> JSM JSVal
forall a. ToJSString a => a -> JSM JSVal
jsg String
"MediaSource") ())
addSourceBuffer ::
(MonadDOM m, ToJSString type') =>
MediaSource -> type' -> m SourceBuffer
addSourceBuffer :: forall (m :: * -> *) type'.
(MonadDOM m, ToJSString type') =>
MediaSource -> type' -> m SourceBuffer
addSourceBuffer MediaSource
self type'
type'
= DOM SourceBuffer -> m SourceBuffer
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
((MediaSource
self MediaSource
-> Getting (JSM JSVal) MediaSource (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"addSourceBuffer" [type' -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal type'
type']) JSM JSVal -> (JSVal -> DOM SourceBuffer) -> DOM SourceBuffer
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
JSVal -> DOM SourceBuffer
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)
addSourceBuffer_ ::
(MonadDOM m, ToJSString type') => MediaSource -> type' -> m ()
addSourceBuffer_ :: forall (m :: * -> *) type'.
(MonadDOM m, ToJSString type') =>
MediaSource -> type' -> m ()
addSourceBuffer_ MediaSource
self type'
type'
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (MediaSource
self MediaSource
-> Getting (JSM JSVal) MediaSource (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"addSourceBuffer" [type' -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal type'
type']))
removeSourceBuffer ::
(MonadDOM m) => MediaSource -> SourceBuffer -> m ()
removeSourceBuffer :: forall (m :: * -> *).
MonadDOM m =>
MediaSource -> SourceBuffer -> m ()
removeSourceBuffer MediaSource
self SourceBuffer
buffer
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (MediaSource
self MediaSource
-> Getting (JSM JSVal) MediaSource (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"removeSourceBuffer" [SourceBuffer -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal SourceBuffer
buffer]))
endOfStream ::
(MonadDOM m) => MediaSource -> Maybe EndOfStreamError -> m ()
endOfStream :: forall (m :: * -> *).
MonadDOM m =>
MediaSource -> Maybe EndOfStreamError -> m ()
endOfStream MediaSource
self Maybe EndOfStreamError
error
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (MediaSource
self MediaSource
-> Getting (JSM JSVal) MediaSource (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"endOfStream" [Maybe EndOfStreamError -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe EndOfStreamError
error]))
isTypeSupported ::
(MonadDOM m, ToJSString type') => type' -> m Bool
isTypeSupported :: forall (m :: * -> *) type'.
(MonadDOM m, ToJSString type') =>
type' -> m Bool
isTypeSupported type'
type'
= DOM Bool -> m Bool
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(((String -> JSM JSVal
forall a. ToJSString a => a -> JSM JSVal
jsg String
"MediaSource") JSM JSVal
-> Getting (JSM JSVal) (JSM JSVal) (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"isTypeSupported" [type' -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal type'
type']) JSM JSVal -> (JSVal -> DOM Bool) -> DOM Bool
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
JSVal -> DOM Bool
forall value. ToJSVal value => value -> DOM Bool
valToBool)
isTypeSupported_ :: (MonadDOM m, ToJSString type') => type' -> m ()
isTypeSupported_ :: forall (m :: * -> *) type'.
(MonadDOM m, ToJSString type') =>
type' -> m ()
isTypeSupported_ type'
type'
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
((String -> JSM JSVal
forall a. ToJSString a => a -> JSM JSVal
jsg String
"MediaSource") JSM JSVal
-> Getting (JSM JSVal) (JSM JSVal) (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"isTypeSupported" [type' -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal type'
type']))
setLiveSeekableRange ::
(MonadDOM m) => MediaSource -> Double -> Double -> m ()
setLiveSeekableRange :: forall (m :: * -> *).
MonadDOM m =>
MediaSource -> Double -> Double -> m ()
setLiveSeekableRange MediaSource
self Double
start Double
end
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
(MediaSource
self MediaSource
-> Getting (JSM JSVal) MediaSource (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"setLiveSeekableRange" [Double -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Double
start, Double -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Double
end]))
clearLiveSeekableRange :: (MonadDOM m) => MediaSource -> m ()
clearLiveSeekableRange :: forall (m :: * -> *). MonadDOM m => MediaSource -> m ()
clearLiveSeekableRange MediaSource
self
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (MediaSource
self MediaSource
-> Getting (JSM JSVal) MediaSource (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> () -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"clearLiveSeekableRange" ()))
getSourceBuffers ::
(MonadDOM m) => MediaSource -> m SourceBufferList
getSourceBuffers :: forall (m :: * -> *).
MonadDOM m =>
MediaSource -> m SourceBufferList
getSourceBuffers MediaSource
self
= DOM SourceBufferList -> m SourceBufferList
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MediaSource
self MediaSource
-> Getting (JSM JSVal) MediaSource (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaSource (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"sourceBuffers") JSM JSVal
-> (JSVal -> DOM SourceBufferList) -> DOM SourceBufferList
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM SourceBufferList
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)
getActiveSourceBuffers ::
(MonadDOM m) => MediaSource -> m SourceBufferList
getActiveSourceBuffers :: forall (m :: * -> *).
MonadDOM m =>
MediaSource -> m SourceBufferList
getActiveSourceBuffers MediaSource
self
= DOM SourceBufferList -> m SourceBufferList
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
((MediaSource
self MediaSource
-> Getting (JSM JSVal) MediaSource (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaSource (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"activeSourceBuffers") JSM JSVal
-> (JSVal -> DOM SourceBufferList) -> DOM SourceBufferList
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM SourceBufferList
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)
setDuration :: (MonadDOM m) => MediaSource -> Double -> m ()
setDuration :: forall (m :: * -> *). MonadDOM m => MediaSource -> Double -> m ()
setDuration MediaSource
self Double
val
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (MediaSource
self MediaSource -> Getting (DOM ()) MediaSource (DOM ()) -> DOM ()
forall s a. s -> Getting a s a -> a
^. String
-> JSM JSVal
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
forall name val.
(ToJSString name, ToJSVal val) =>
name
-> val
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
jss String
"duration" (Double -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Double
val))
getDuration :: (MonadDOM m) => MediaSource -> m Double
getDuration :: forall (m :: * -> *). MonadDOM m => MediaSource -> m Double
getDuration MediaSource
self
= DOM Double -> m Double
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MediaSource
self MediaSource
-> Getting (JSM JSVal) MediaSource (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaSource (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"duration") JSM JSVal -> (JSVal -> DOM Double) -> DOM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM Double
forall value. ToJSVal value => value -> DOM Double
valToNumber)
getReadyState :: (MonadDOM m) => MediaSource -> m ReadyState
getReadyState :: forall (m :: * -> *). MonadDOM m => MediaSource -> m ReadyState
getReadyState MediaSource
self
= DOM ReadyState -> m ReadyState
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((MediaSource
self MediaSource
-> Getting (JSM JSVal) MediaSource (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter MediaSource (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"readyState") JSM JSVal -> (JSVal -> DOM ReadyState) -> DOM ReadyState
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM ReadyState
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)
sourceopen :: EventName MediaSource onsourceopen
sourceopen :: forall onsourceopen. EventName MediaSource onsourceopen
sourceopen = DOMString -> EventName MediaSource onsourceopen
forall t e. DOMString -> EventName t e
unsafeEventName (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"sourceopen")
sourceended :: EventName MediaSource onsourceended
sourceended :: forall onsourceopen. EventName MediaSource onsourceopen
sourceended = DOMString -> EventName MediaSource onsourceended
forall t e. DOMString -> EventName t e
unsafeEventName (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"sourceended")
sourceclose :: EventName MediaSource onsourceclose
sourceclose :: forall onsourceopen. EventName MediaSource onsourceopen
sourceclose = DOMString -> EventName MediaSource onsourceclose
forall t e. DOMString -> EventName t e
unsafeEventName (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"sourceclose")