Skip to content

Instantly share code, notes, and snippets.

@gigafied
Created October 29, 2015 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gigafied/e178b7fbea57ec2b9544 to your computer and use it in GitHub Desktop.
Save gigafied/e178b7fbea57ec2b9544 to your computer and use it in GitHub Desktop.
UniFi Video - RTMP Streaming
(function () {
'use strict';
function initPlayer (url) {
jwplayer('playerID').setup({
file : url,
image: '//www.longtailvideo.com/content/images/jw-player/lWMJeVvV-876.jpg',
width: '50%',
primary: 'flash',
aspectratio: '16:9'
});
}
function loadStream (host, cameraId, channel, apiKey) {
var url = [host, 'stream', cameraId, channel, 'url'].join('/');
url += '?apiKey=' + apiKey;
$.ajax({
url : url,
xhrFields: {
withCredentials: true
}}
).then(function (json) {
json = json.data[0];
initPlayer([json.rtmpPath, json.streamName].join('/'))
});
}
loadStream(
'http://192.168.0.200:7080/api/2.0', // HOST
'ABC1234', // CAMERA ID
'1', // CHANNEL
'ZZZZZZZZ' // API KEY
);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment