-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add wip example of using elm-usermedia to get a stream for MediaStrea…
…mAudioSourceNode
- Loading branch information
giraj
committed
Jul 15, 2015
1 parent
04e487c
commit aedb5f9
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |