<mediastream>
Allows video playback, live broadcast or recording .

JavaScript: lz.mediastream
extends <node> » lz.Eventable »

<mediastream> allows applications to stream video from HTTP or RTMP servers. Classes like <videoview> use mediastreams to handle the connection to the server.

<canvas>
            <mediastream name="ms" autoplay="true" type="http" url="http://www.archive.org/download//JudgeMediaTestVideoFile_0/video.flv"/>
            <videoview type="http" autoplay="true" width="320" height="240" stream="canvas.ms"/>
        </canvas>

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
autoplay boolean Boolean false read/write
  If true, video will start playing as soon as url is set.
autoplayLength expression String 'end' read/write
  Autoplay length argument passed to mediastream.play(). See the mediastream.play documentation for its values.
autoplayPause boolean Boolean false read/write
  Autoplay pause argument passed to mediastream.play(). See the mediastream.play documentation for its values.
autoplayReset expression Boolean true read/write
  Autoplay reset argument passed to mediastream.play(). See the mediastream.play documentation for its values.
autoplayStart expression String 'either' read/write
  Autoplay start argument passed to mediastream.play(). See the mediastream.play documentation for its values.
autorewind boolean Boolean true read/write
  If true, video will automatically rewind to the beginning (and remain in a paused state) when playback ends.
broadcasting expression Boolean (this.mode == 'broadcasting') || (this.mode == 'recording') readonly
  True if broadcasting right now.
buffertime number Number 0.1 read/write
  Amount of time (in seconds) to buffer before starting to display the stream. For a publishing stream, bufferTime specifies how long the outgoing buffer can grow before the application starts dropping frames.
cam expression lz.camera null readonly
  A reference to the camera. This must be set if broadcasting. This is set automatically if the stream is a child of a videoview.
debug expression Boolean false read/write
  When true, print extra info to the debugger.
fps number Number 0 read/write
  The current frames per second for playing video.
mic expression lz.microphone null readonly
  A reference to the microphone. This must be set if broadcasting. This is set automatically if the stream is a child of a videoview.
mode string String   read/write
  Mode: "" if doing nothing, "playing" if playing, "broadcasting" if can be received, "recording" if recording. Recording also implies can be received, i.e., broadcasting. Pausing does not affect the mode, unlike stopping.
muteaudio expression Boolean false readonly
  True iff audio is muted.
mutevideo expression Boolean false readonly
  True iff video is muted.
paused boolean Boolean false read/write
  True to pause playback. Named this way to pun with paused for animators.
playing expression Boolean (this.mode == 'playing') && (!this.paused) readonly
  True if playing right now.
progress number Number 0 read/write
  Progress of mediastream currently downloading. (from 0 for none to 1 for all).
recording expression Boolean this.mode == 'recording' readonly
  True if recording right now.
rtmp expression lz.rtmpconnection null read/write
  The rtmp connection to use (defaults to the first one created).
streamname string String   read/write
  The rtmp streamname (without .flv suffix).
time number Number 0 readonly
  Current time of mediastream currently playing or recording (in seconds)
totaltime number Number 0 readonly
  Total length (in seconds) of mediastream currently playing.
type string String http read/write
  Protocol "rtmp" or "http".
url string String   read/write
  The url of the mediastream, maybe be relative URL, for example: http://localhost/myvideo.flv, or simply myvideo.flv when type="rtmp" the url is always relative to the rtmpconnection.

Methods

broadcast()
mediastream.broadcast();
start sending a live mediastream to the server.

close()
mediastream.close();

pause()
mediastream.pause(p);
Pause playback. If no argument is given, then this toggles the pause/play state. To explicitly pause, call pause(true) to explicitly resume, call pause(false)
Parameter Name Type Description
p    

play()
mediastream.play(start, pause, length, reset);
play
Parameter Name Type Description
start    
pause    
length    
reset    

record()
mediastream.record();
Start recording.

seek()
mediastream.seek(t);
seek to a particular time (t) in seconds. If the stream is playing when seek is called, it will not pause playback but rather start playing from the given time. If the stream is paused or not yet playing, then the frame at the given time will be displayed and the stream will be in a paused state.
Parameter Name Type Description
t    

stop()
mediastream.stop();
stop will stop everything: playback, recording and broadcasting. It also resets the time to the beginning and the mode to ""

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
oncuepoint Event sent when a cue point occurs, whose parameter is a dictionary of metadata.
oninsufficientbandwidth Event sent when insufficient bandwidth.
onmetadata Event sent when metadata is received, whose parameter is a dictionary of metadata.
onstart Event sent when playing or recording starts.
onstop Event sent when playing or recording stops.

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy