Live streams in your plugin
Live streaming anywhere on a site: your plugin can let every member go live, give each of its groups, courses, events or rooms a stream of its own, put a post in a feed while someone is live, and show any stream on its own screens, with your rules for who goes live and who watches. Live Stream shows its streams in the chat rooms of Better Messages the way they show a group call (Chat), and your plugin can do the same.
What you can build
- Streams of your users. Every member, or those you choose, goes live in a stream of their own, which they host, from a page or a screen of yours: made in PHP, or from the browser with a Go live button.
- A stream for each thing of yours. Make, change and delete streams from PHP, each one made for a thing of your plugin, and find it again by that thing.
- Live posts and notices. PHP actions as a stream goes live and ends, for a post in a feed while a member is live, a notice to their followers, or how long it lasted.
- The stream on your screens. In one piece, in a ready layout, or in parts (the player, the chat, the studio, the details), from PHP or from JavaScript, and shared and listed as live from the page you say it is watched on.
- Your rules. Who hosts each stream, who watches it, who writes in its chat and who moderates it, and who makes streams of their own.
- Going live where your people are. Hosts go live from the studio you put on your pages, with no access to the WordPress admin.
- What is live. In PHP, and in the browser the moment a stream goes live or ends, with how many watch.
The pieces
| Piece | What it is for |
|---|---|
| PHP | Making streams, of your users or for things of yours, and finding them, showing them, asking who may do what and what is live. |
| Hooks | Your rules for who hosts, watches, chats, moderates and makes streams, and where streams are watched. Actions as streams go live and end, and as they are made, changed and deleted. |
| JavaScript | Showing a stream from your script, a Go live button that makes a stream of the user, and hearing when a stream goes live or ends, how many watch and its messages. |
| REST | The config of a stream, for a screen drawn in the browser, and the streams of a user. |
Two whole plugins built on them, each about 100 lines: members going live, with a post up while they are live, and live events, each with a stream its organiser hosts and the people going watch.
Start
Live Stream may be missing or turned off on a site, so check that it is there once plugins have loaded:
add_action( 'plugins_loaded', function () {
if ( ! function_exists( 'wordplus_streams' ) ) {
return; // No live streams on this site.
}
// Your integration.
} );
wordplus_streams()->can_stream() says whether the site can stream: it has its licence, and the licence includes live streaming. Leave your own Go live buttons out until it does.
A stream for a thing of yours
$stream_id = wordplus_streams()->create( array(
'title' => 'Weekly class',
'object_type' => 'my_course',
'object_id' => 42,
'settings' => array( 'access' => 'logged_in', 'chat_with' => 'light' ),
) );
// Later, on the page of the course.
$stream = wordplus_streams()->get_object_stream( 'my_course', 42 );
if ( $stream ) {
echo wordplus_streams()->render( $stream['id'], array( 'layout' => 'side' ) );
}
It is a stream like any other: administrators find it in Live Stream → Studio, change its settings there, and go live in it. Your hooks decide who else does (Hooks).
Names
Everything you build on is named for WordPlus, which makes Live Stream, so it stays whatever the plugin is called:
| PHP | wordplus_streams() |
| Hooks | wordplus_stream_…, as wordplus_stream_live |
| Script handles | wordplus-streams, wordplus-streams-live |
| JavaScript | window.wordplusStreams |
| REST | /wp-json/wordplus/v1/streams |
Viewers
The viewers of the streams on your screens are viewers of the site, as on any page, and those of your members too: every stream of the site shares its unmetered viewers and its credits (Viewers and credits).
In the beta
Live Stream is in beta, and so is what you build on. Tell us what you build and what you miss: contact us.