rtc-ui
v1.1.2
Published
Common UI interaction patterns for working with rtc.io modules
Downloads
6
Readme
rtc-ui
This is a collection of user interface helper functions that can be used in conjunction with other rtc.io modules.
Reference
rtc-ui/stream
Provides a number of helper functions for rendering both local and remote
streams to the DOM. Also provides a top level streamui
function that chain
be used as a quickconnect "plugin" to automatically wire up these helper
functions for typical usage.
An example of usage is provided below:
var quickconnect = require('rtc-quickconnect');
var capture = require('rtc-capture');
var streamui = require('rtc-ui/stream');
var conference;
capture({ video: true, audio: true }, function(err, stream) {
if (err) {
return console.error(err);
}
// create the conference
conference = quickconnect('https://switchboard.rtc.io/', {
room: 'rtc-ui:conference-example'
});
// add the local stream to the conference
conference.addStream(stream);
// render the local stream using the stream ui
streamui.local(document.body)(stream);
// use streamui to automatically handle element creation and removal
streamui(conference, { container: document.body });
});
streamui(qc, opts)
Link standard quickconnect events to sensible streamui handlers. Use opts
to provide configuration to the handler functions, notably:
container
- the container element in which new elements will be created within and searches for element removal will be constrained to. Defaults todocument.body
.plugins
- If you are using any rtc.io plugins specify these here to have them passed on tortc-attach
for integration.
streamui.local(container, opts?) => fn(stream)
Create a handler function specifying a target container and any
additional options. The handler function expects a single argument
of stream
for which a rendering element will be created and added
to the specified container.
This element will have the rtc
abd localvideo
classes applied to
it so can be styled using CSS by your app.
streamui.add(container, opts?) => fn(id, stream)
Create a handler function that is designed to respond to stream:added
events generated by rtc-quickconnect
(i.e it follows the (id, stream)
function
signature). A renderer element will be created for the stream and appended
to the container
element.
This element will have the rtc
and remotevideo
classes applied to it, and
will also have data-peer
and data-stream
attributes set on the created
element.
streamui.remove(container, opts?) => fn(id, stream?)
Create a handler function that is designed to respond to both stream:removed
and call:ended
events generated by rtc-quickconnect
. When the handler is
invoked with just an id, all elements with the data-peer
matching the
specified value will be removed from container
. If a stream
argument value
is supplied, then only those matching the data-stream
label will be removed.
License(s)
ISC
Copyright (c) 2015, National ICT Australia Limited (NICTA)
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.