jsaddle-dom-0.10.0.0: src/JSDOM/Generated/EncodedVideoChunk.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from webcodecs (webref). Do not edit.
module JSDOM.Generated.EncodedVideoChunk
(newEncodedVideoChunk, copyTo, getType, getTimestamp, getDuration, getDurationUnsafe, getDurationUnchecked, getByteLength, EncodedVideoChunk(..), gTypeEncodedVideoChunk)
where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums
-- | <https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/EncodedVideoChunk MDN EncodedVideoChunk. documentation>
newEncodedVideoChunk :: (MonadDOM m) => EncodedVideoChunkInit -> m EncodedVideoChunk
newEncodedVideoChunk init = liftDOM (((new (jsg "EncodedVideoChunk") [toJSVal init]) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/copyTo MDN EncodedVideoChunk.copyTo documentation>
copyTo :: (MonadDOM m, IsAllowSharedBufferSource destination) => EncodedVideoChunk -> destination -> m ()
copyTo self destination = liftDOM (void (self ^. jsf "copyTo" [toJSVal destination]))
-- | <https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/type MDN EncodedVideoChunk.type documentation>
getType :: (MonadDOM m) => EncodedVideoChunk -> m EncodedVideoChunkType
getType self = liftDOM (((self ^. js "type") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/timestamp MDN EncodedVideoChunk.timestamp documentation>
getTimestamp :: (MonadDOM m) => EncodedVideoChunk -> m Int53
getTimestamp self = liftDOM (((self ^. js "timestamp") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/duration MDN EncodedVideoChunk.duration documentation>
getDuration :: (MonadDOM m) => EncodedVideoChunk -> m (Maybe Word53)
getDuration self = liftDOM (((self ^. js "duration") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/duration MDN EncodedVideoChunk.duration documentation>
getDurationUnsafe :: (MonadDOM m, HasCallStack) => EncodedVideoChunk -> m Word53
getDurationUnsafe self = liftDOM ((((self ^. js "duration") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/duration MDN EncodedVideoChunk.duration documentation>
getDurationUnchecked :: (MonadDOM m) => EncodedVideoChunk -> m Word53
getDurationUnchecked self = liftDOM (((self ^. js "duration") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/byteLength MDN EncodedVideoChunk.byteLength documentation>
getByteLength :: (MonadDOM m) => EncodedVideoChunk -> m Word
getByteLength self = liftDOM ((P.round <$> ((self ^. js "byteLength") >>= valToNumber)))