Skip to content

Commit

Permalink
add wip example of using elm-usermedia to get a stream for MediaStrea…
Browse files Browse the repository at this point in the history
…mAudioSourceNode
  • Loading branch information
giraj committed Jul 15, 2015
1 parent 04e487c commit aedb5f9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/Stream.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import UserMedia exposing (MediaStream, requestUserMedia)
import WebAudio exposing (..)
import Task as T
import Signal as S exposing ((<~))
import Html exposing (div, text)

view model =
case model of
Nothing -> div [] [ text "Nothing" ]
Just stream ->
-- I would expect this to immediately feed me back the microphone input
let node = createMediaStreamSourceNode DefaultContext stream
|> connectNodes (getDestinationNode DefaultContext) 0 0
in
div [] [ text "Got user media" ]

{-| send one time request for usermedia, stream is then forwarded to the
mailbox
-}
port getUserMedia : T.Task x ()
port getUserMedia =
requestUserMedia userMediaStream.address { audio=True, video=False }

userMediaStream : S.Mailbox (Maybe MediaStream)
userMediaStream =
S.mailbox Nothing


main =
view <~ userMediaStream.signal

0 comments on commit aedb5f9

Please sign in to comment.