mirror of https://github.com/calzoneman/sync.git
Add JWPlayer support
This commit is contained in:
parent
4bdbac3dbd
commit
7f7ae16138
33
channel.js
33
channel.js
|
@ -603,6 +603,13 @@ function mediaUpdate(chan, id) {
|
||||||
setTimeout(function() { mediaUpdate(chan, id); }, 1000);
|
setTimeout(function() { mediaUpdate(chan, id); }, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isLive(type) {
|
||||||
|
return type == "li"
|
||||||
|
|| type == "tw"
|
||||||
|
|| type == "rt"
|
||||||
|
|| type == "jw";
|
||||||
|
}
|
||||||
|
|
||||||
Channel.prototype.enqueue = function(data, user) {
|
Channel.prototype.enqueue = function(data, user) {
|
||||||
var idx = data.pos == "next" ? this.position + 1 : this.queue.length;
|
var idx = data.pos == "next" ? this.position + 1 : this.queue.length;
|
||||||
|
|
||||||
|
@ -668,9 +675,18 @@ Channel.prototype.enqueue = function(data, user) {
|
||||||
});
|
});
|
||||||
this.broadcastPlaylistMeta();
|
this.broadcastPlaylistMeta();
|
||||||
break;
|
break;
|
||||||
|
case "jw":
|
||||||
|
var media = new Media(data.id, "JWPlayer Stream - " + data.id, "--:--", "jw");
|
||||||
|
media.queueby = user ? user.name : "";
|
||||||
|
this.queue.splice(idx, 0, media);
|
||||||
|
this.sendAll("queue", {
|
||||||
|
media: media.pack(),
|
||||||
|
pos: idx
|
||||||
|
});
|
||||||
|
this.broadcastPlaylistMeta();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -784,9 +800,7 @@ Channel.prototype.playNext = function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// If it's not a livestream, enable autolead
|
// If it's not a livestream, enable autolead
|
||||||
if(this.leader == null && this.media.type != "tw"
|
if(this.leader == null && !isLive(this.media.type)) {
|
||||||
&& this.media.type != "li"
|
|
||||||
&& this.media.type != "rt") {
|
|
||||||
this.time = new Date().getTime();
|
this.time = new Date().getTime();
|
||||||
if(this.media.id != oid) {
|
if(this.media.id != oid) {
|
||||||
mediaUpdate(this, this.media.id);
|
mediaUpdate(this, this.media.id);
|
||||||
|
@ -829,9 +843,7 @@ Channel.prototype.jumpTo = function(pos) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// If it's not a livestream, enable autolead
|
// If it's not a livestream, enable autolead
|
||||||
if(this.leader == null && this.media.type != "tw"
|
if(this.leader == null && !isLive(this.media.type)) {
|
||||||
&& this.media.type != "li"
|
|
||||||
&& this.media.type != "rt") {
|
|
||||||
this.time = new Date().getTime();
|
this.time = new Date().getTime();
|
||||||
if(this.media.id != oid) {
|
if(this.media.id != oid) {
|
||||||
mediaUpdate(this, this.media.id);
|
mediaUpdate(this, this.media.id);
|
||||||
|
@ -908,8 +920,7 @@ Channel.prototype.tryUpdate = function(user, data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.media.type == "li" || this.media.type == "tw" ||
|
if(isLive(this.media.type)) {
|
||||||
this.media.type == "rt") {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1284,9 +1295,7 @@ Channel.prototype.changeLeader = function(name) {
|
||||||
}
|
}
|
||||||
if(name == "") {
|
if(name == "") {
|
||||||
this.logger.log("*** Resuming autolead");
|
this.logger.log("*** Resuming autolead");
|
||||||
if(this.media != null && this.media.type != "li"
|
if(this.media != null && !isLive(this.media.type)) {
|
||||||
&& this.media.type != "tw"
|
|
||||||
&& this.media.type != "rt") {
|
|
||||||
this.time = new Date().getTime();
|
this.time = new Date().getTime();
|
||||||
this.i = 0;
|
this.i = 0;
|
||||||
mediaUpdate(this, this.media.id);
|
mediaUpdate(this, this.media.id);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const VERSION = "1.4.1";
|
const VERSION = "1.4.2";
|
||||||
|
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var Logger = require("./logger.js");
|
var Logger = require("./logger.js");
|
||||||
|
|
|
@ -427,6 +427,10 @@ function parseVideoURL(url){
|
||||||
url = url.trim()
|
url = url.trim()
|
||||||
if(typeof(url) != "string")
|
if(typeof(url) != "string")
|
||||||
return null;
|
return null;
|
||||||
|
if(url.indexOf("jw:") == 0) {
|
||||||
|
url = url.substring(3);
|
||||||
|
return [url, "jw"];
|
||||||
|
}
|
||||||
if(url.indexOf("rtmp://") == 0) {
|
if(url.indexOf("rtmp://") == 0) {
|
||||||
return [url, "rt"];
|
return [url, "rt"];
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,9 @@ var Media = function(data) {
|
||||||
case "rt":
|
case "rt":
|
||||||
this.initRTMP();
|
this.initRTMP();
|
||||||
break;
|
break;
|
||||||
|
case "jw":
|
||||||
|
this.initJWPlayer();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -278,6 +281,31 @@ Media.prototype.initRTMP = function() {
|
||||||
this.seek = function() { }
|
this.seek = function() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Media.prototype.initJWPlayer = function() {
|
||||||
|
this.removeOld();
|
||||||
|
|
||||||
|
jwplayer("ytapiplayer").setup({
|
||||||
|
file: this.id,
|
||||||
|
width: VWIDTH,
|
||||||
|
height: VHEIGHT,
|
||||||
|
autostart: true
|
||||||
|
});
|
||||||
|
setTimeout(function() {$("#ytapiplayer_logo").remove();}, 1000);
|
||||||
|
|
||||||
|
this.load = function(data) {
|
||||||
|
this.id = data.id;
|
||||||
|
this.initJWPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pause = function() { }
|
||||||
|
|
||||||
|
this.play = function() { }
|
||||||
|
|
||||||
|
this.getTime = function() { }
|
||||||
|
|
||||||
|
this.seek = function() { }
|
||||||
|
}
|
||||||
|
|
||||||
Media.prototype.update = function(data) {
|
Media.prototype.update = function(data) {
|
||||||
if(data.id != this.id) {
|
if(data.id != this.id) {
|
||||||
if(data.currentTime < 0) {
|
if(data.currentTime < 0) {
|
||||||
|
|
|
@ -130,15 +130,17 @@
|
||||||
<li>http://www.dailymotion.com/video/(videoid)</li>
|
<li>http://www.dailymotion.com/video/(videoid)</li>
|
||||||
<li>http://www.twitch.tv/(channel)</li>
|
<li>http://www.twitch.tv/(channel)</li>
|
||||||
<li>http://www.livestream.com/(channel)</li>
|
<li>http://www.livestream.com/(channel)</li>
|
||||||
|
<li>rtmp://(stream url)</li>
|
||||||
|
<li>jw:(stream url) - uses a JWPlayer embed (use this for audio streams)
|
||||||
</ul>
|
</ul>
|
||||||
You can also queue multiple items at once by separating the URLs with commas.
|
You can also queue multiple items at once by separating the URLs with commas.
|
||||||
<div>
|
<div>
|
||||||
<input type="text" id="mediaurl" style="margin:auto;">
|
<input type="text" id="mediaurl" style="margin:auto;">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn">Queue Next</button>
|
<button class="btn">Next</button>
|
||||||
<button class="btn">Queue @ End</button>
|
<button class="btn">End</button>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-danger">Voteskip</button>
|
<button class="btn btn-block">Voteskip</button>
|
||||||
</div>
|
</div>
|
||||||
<p>Below is an example of an entry in the playlist. Please note the control buttons only appear if you are a moderator or if the queue is unlocked. The button with vertical arrows is for moving videos in the playlist. Click and hold the button and drag the mouse up and down to move the video in the playlist. The red "X" button will remove the video from the playlist. The green play button will jump the playlist to that video. The "Next" button will move the video so that it plays after the current video.
|
<p>Below is an example of an entry in the playlist. Please note the control buttons only appear if you are a moderator or if the queue is unlocked. The button with vertical arrows is for moving videos in the playlist. Click and hold the button and drag the mouse up and down to move the video in the playlist. The red "X" button will remove the video from the playlist. The green play button will jump the playlist to that video. The "Next" button will move the video so that it plays after the current video.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -254,6 +254,7 @@
|
||||||
|
|
||||||
<!-- APIs -->
|
<!-- APIs -->
|
||||||
<script src="http://api.dmcdn.net/all.js"></script>
|
<script src="http://api.dmcdn.net/all.js"></script>
|
||||||
|
<script src="http://jwpsrv.com/library/QouFCLBMEeKC+CIACpYGxA.js"></script>
|
||||||
<script src="./assets/js/sc.js"></script>
|
<script src="./assets/js/sc.js"></script>
|
||||||
<script src="./assets/js/froogaloop.min.js"></script>
|
<script src="./assets/js/froogaloop.min.js"></script>
|
||||||
<script src="./assets/js/swf.js"></script>
|
<script src="./assets/js/swf.js"></script>
|
||||||
|
|
Loading…
Reference in New Issue