Skip to content

Commit a66bf90

Browse files
committed
Add srcObject.
Allows setting the stream on <audio> / <video> elements. Useful for camera.
1 parent da29a6b commit a66bf90

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Miso/Media.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module Miso.Media
2727
, play
2828
, pause
2929
, getUserMedia
30+
, srcObject
3031
-- *** Properties
3132
, autoplay
3233
, controls
@@ -60,7 +61,7 @@ import qualified Language.Javascript.JSaddle as JS
6061
import qualified Miso.FFI.Internal as FFI
6162
import Miso.FFI
6263
import Miso.Event
63-
import Miso.Effect
64+
import Miso.Effect hiding ((<#))
6465
import Miso.String
6566
-----------------------------------------------------------------------------
6667
newtype Media = Media JSVal
@@ -215,6 +216,10 @@ userMedia = UserMedia True True
215216
-----------------------------------------------------------------------------
216217
type Stream = JSVal
217218
-----------------------------------------------------------------------------
219+
-- | Sets the `srcObject` on audio or video elements.
220+
srcObject :: Stream -> Media -> JSM ()
221+
srcObject stream (Media media) = media <# ("srcObject" :: MisoString) $ stream
222+
-----------------------------------------------------------------------------
218223
-- | Get access to user's media devices.
219224
--
220225
-- <https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia>

0 commit comments

Comments
 (0)