Skip to content

Instantly share code, notes, and snippets.

@oeway
Last active April 21, 2020 08:15
Show Gist options
  • Save oeway/279c412350d53de07db8760141667b31 to your computer and use it in GitHub Desktop.
Save oeway/279c412350d53de07db8760141667b31 to your computer and use it in GitHub Desktop.
<docs lang="markdown">
[TODO: write documentation for this plugin.]
</docs>
<config lang="json">
{
"name": "UC2-Streamer",
"type": "window",
"tags": [],
"ui": "",
"version": "0.1.1",
"cover": "",
"description": "[TODO: describe this plugin with one sentence.]",
"icon": "extension",
"inputs": null,
"outputs": null,
"api_version": "0.1.8",
"env": "",
"permissions": [],
"requirements": [
"https://horrible-fly-95.telebit.io/libs/request.min.js",
"https://horrible-fly-95.telebit.io/libs/adapter.min.js",
"https://horrible-fly-95.telebit.io/webrtcstreamer.js"],
"dependencies": [],
"defaults": {"w": 20, "h": 10, "fullscreen": true}
}
</config>
<script lang="javascript">
class ImJoyPlugin {
async setup() {
api.log('initialized')
}
async run(ctx) {
var webrtcConfig = {
url: "https://horrible-fly-95.telebit.io" ,
options: "rtptransport=tcp&timeout=60",
layoutextraoptions: "&width=320&height=0",
defaultvideostream: "Bunny"
}
var url = { video:"mmal service 16.1" };
var options = webrtcConfig.options;
if (typeof URLSearchParams != 'undefined') {
var params = new URLSearchParams(location.search);
if (params.has("video") || params.has("audio")) {
url = { video:params.get("video"), audio:params.get("audio") };
}
if (params.has("options")) {
options = params.get("options");
}
}
const webRtcServer = new WebRtcStreamer("video", webrtcConfig.url);
document.getElementById("title").innerHTML=url.video;
webRtcServer.connect(url.video,url.audio,options);
request("GET" , webrtcConfig.url + "/api/version").done( function (response) {
document.getElementById("footer").innerHTML = "<p><a href='https://github.com/mpromonet/webrtc-streamer'>WebRTC-Streamer</a> " + JSON.parse(response.body).split(" ")[0] + "</p>";
});
}
}
api.export(new ImJoyPlugin())
</script>
<window lang="html">
<div>
<h2 id="title"></h2>
<video id="video" muted></video>
<footer id="footer"></footer>
</div>
</window>
<style lang="css">
#video {
width: 100%;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment