Skip to content

Commit

Permalink
v1.5.0 LiveTv support
Browse files Browse the repository at this point in the history
  • Loading branch information
sleuth255 committed Feb 7, 2019
1 parent b5b4f3a commit bd85660
Show file tree
Hide file tree
Showing 17 changed files with 2,543 additions and 1,422 deletions.
2 changes: 1 addition & 1 deletion appinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"id": "theparadigmgrid.screenplay",
"title": "screenplay",
"type": "web",
"version": "1.4.1"
"version": "1.5.0"
}
Binary file added images/generic-backdrop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 67 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@
<script type="text/javascript" src="./script/models/collection.js"></script>
<script type="text/javascript" src="./script/models/collection.summary.js"></script>
<script type="text/javascript" src="./script/models/item.js"></script>
<script type="text/javascript" src="./script/models/playerloader.js"></script>
<script type="text/javascript" src="./script/models/player.js"></script>
<script type="text/javascript" src="./script/models/livetv.js"></script>

<script type="text/javascript">
dom.on(document, "DOMContentLoaded", function() {
var splash = new Splash();
var server = new Server();
var user = new User();
var home = new Home();
var collection = new Collection();
var collection = new Collection();
var livetv = new LiveTv();
var summary = new CollectionSummary();
var item = new Item();
var playerloader = new PlayerLoader();
var player = new Player();
var controlsVisible = false;
var subtitlesVisible = true;
Expand All @@ -52,7 +56,6 @@

dom.on(document, "userAuthenticated", function(event) {
user.close();
dom.remove("#home")
home.load();
});

Expand All @@ -63,6 +66,13 @@
prefs.clientSettings();
});

dom.on(document, "userLiveTvSelected", function(event) {
history.pushState({
action: "livetv"
}, "livetv");
livetv.load(false);
});

dom.on(document, "userViewSelected", function(event) {
history.pushState({
action: "summary",
Expand Down Expand Up @@ -96,6 +106,8 @@

dom.on(document, "mediaItemSelected", function(event) {
collection.close()
home.close();
livetv.close()
history.pushState({
action: "item",
id: event.detail.id
Expand All @@ -104,10 +116,20 @@
});

dom.on(document, "playItem", function(event) {
history.pushState({
action: "item",
id: event.detail.id
}, "item");
controlsVisible =false;
subtitlesVisible = true;
firstEvent = true;
player.load(event.detail);
playerloader.load(event.detail)
});
dom.on(document, "launchPlayer", function(event) {
controlsVisible =false;
subtitlesVisible = true;
firstEvent = true;
player.load(event.detail);
});
dom.on(document, "reloadItem", function(event) {
item.close()
Expand All @@ -120,27 +142,25 @@
});
item.close();
collection.close();
home.close();
livetv.close();
summary.close();
home.load()
});


window.addEventListener("popstate", function(event) {
if (dom.exists("#player"))
if (firstEvent)
{
firstEvent = false;
return;
}
else
{
player.close()
return;
}
{
player.close()
return;
}
if (event.state) {
collection.close();
livetv.close();
summary.close();
home.close();
item.close();
switch(event.state.action) {
case "home":
home.load();
Expand All @@ -154,16 +174,32 @@
collection.load(event.state,true);
break;

case "livetv":
livetv.load(true);
break;

case "item":
item.load(event.state.id,true);
break;

case "settings":
prefs.clientSettings(event.state.id);
break;
}
}
else
home.load()
{
if (dom.exists('#home'))
playerpopup.show({
duration: 2000,
text: "Press MENU to exit"
});

history.pushState({
action: "home"
}, "home");

}
});

dom.on("#homeLink a", "click", function(event) {
Expand All @@ -173,6 +209,8 @@
action: "home"
}, "home");
collection.close();
home.close();
livetv.close();
summary.close();
home.close();
home.load();
Expand All @@ -187,21 +225,25 @@
});

dom.on("#server", "click", function(event) {
event.preventDefault()
event.stopPropagation();
home.close();
server.add();
});

dom.on("#user", "click", function(event) {
event.stopPropagation()
event.preventDefault()
event.stopPropagation()
home.close()
user.login();
});

document.addEventListener("keydown", function(event)
{
if (dom.exists("#screenplaySettings"))
if (dom.exists("#screenplaySettings"))
return;

if ((event.which == keys.KEY_RED && Math.floor(prefs.redButton) == 1)
if ((event.which == keys.KEY_RED && Math.floor(prefs.redButton) == 1)
|| (event.which == keys.KEY_GREEN && Math.floor(prefs.greenButton) == 1)
|| (event.which == keys.KEY_YELLOW && Math.floor(prefs.yellowButton) == 1)
|| (event.which == keys.KEY_BLUE && Math.floor(prefs.blueButton) == 1))
Expand Down Expand Up @@ -357,7 +399,13 @@
server.load();
}
});
});
function error(){
playerpopup.show({
duration: 2000,
text: 'Player not loaded'
})
};
});
</script>

<link type="text/css" rel="stylesheet" href="./styles/application.css">
Expand Down
2 changes: 1 addition & 1 deletion script/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function DEVICE() {
this.client = "screenplay";
this.name = "LG Smart TV";
this.id = storage.exists("emby.device.id") ? storage.get("emby.device.id") : storage.set("emby.device.id", guid.create());
this.version = "v1.4.1";
this.version = "v1.5.0";
this.author = "The Paradigm Grid",
this.language = navigator.language;
this.platform = navigator.platform;
Expand Down
90 changes: 88 additions & 2 deletions script/emby.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,55 @@ EMBY.prototype.getUser = function(settings) {
});
};

EMBY.prototype.getLiveTV = function(settings){
settings = settings || {};


ajax.request(this.settings.ServerUrl + "/LiveTV/Info", {
method: "GET",
headers: this.headers(),
success: function(data) {
settings.success(data);
},
error: settings.error
});
};

EMBY.prototype.getLiveTvChannel = function(settings){
settings = settings || {};
var id = settings.id || 0;


ajax.request(this.settings.ServerUrl + "/LiveTV/Channels/"+id, {
method: "GET",
headers: this.headers(),
success: function(data) {
settings.success(data);
},
error: settings.error
});
};

EMBY.prototype.getLiveTvPrograms = function(settings){
settings = settings || {};
var limit = settings.limit || this.limit;
var MaxStartDate = settings.MaxStartDate || this.MaxStartDate;
var HasAired = settings.HasAired || this.HasAired


ajax.request(this.settings.ServerUrl + '/LiveTV/Programs?SortBy=sortName&SortOrder=Ascending'+
(limit ? "&limit=" + limit : "")+
(HasAired ? "&HasAired=" + HasAired : "")+
(MaxStartDate ? "&MaxStartDate=" + MaxStartDate : "") , {
method: "GET",
headers: this.headers(),
success: function(data) {
settings.success(data);
},
error: settings.error
});
};

EMBY.prototype.getUserViews = function(settings) {
settings = settings || {};

Expand Down Expand Up @@ -284,9 +333,7 @@ EMBY.prototype.getVideoStreamUrl = function(settings) {
var audioBitrate = Math.floor(prefs.audioBitrate) || 128000;
var maxAudioChannels = settings.maxAudioChannels || 5;
var direct = settings.direct || "true";
var extension = settings.extension || "";
var playSessionId = settings.playSessionId || "1c7fddb7712646f9ba6352f8d9afc79e"; // not using mediasource api so using random string per api doc;
extension = extension.length > 0 ? "." + extension : extension;

return this.settings.ServerUrl + "/Videos/" + itemId + "/stream" + "?static=" + direct + "&videoBitrate=" + videoBitrate + "&mediaSourceId=" + mediaSourceId +"&playSessionId =" + playSessionId +
"&audioBitrate=" + audioBitrate + "&maxAudioChannels=" + maxAudioChannels + "&api_key=" + this.settings.AccessToken + t;
Expand Down Expand Up @@ -333,6 +380,16 @@ EMBY.prototype.getVideoHlsStreamUrl = function(settings) {

};


EMBY.prototype.getLiveTvHlsStreamUrl = function(settings) {
settings = settings || {};

var itemId = settings.itemid;
var container = settings.container;
return this.settings.ServerUrl + "/videos/" + itemId + "/live.m3u8?id=" + itemId + "&container=" + container;

};

EMBY.prototype.getImageUrl = function(settings) {
settings = settings || {};

Expand Down Expand Up @@ -418,6 +475,35 @@ EMBY.prototype.postSessionPlayingStopped = function(settings) {

};

EMBY.prototype.postLiveStreamClose = function(settings) {
settings = settings || {};
ajax.request(this.settings.ServerUrl + "/liveStreams/Close" , {
method: "POST",
headers: this.headers(),
data: settings.data,
success: function(data) {
settings.success(data);
},
error: settings.error
});

};

EMBY.prototype.postPlaybackInfo = function(settings) {
settings = settings || {};

ajax.request(this.settings.ServerUrl + "/Items/"+settings.id+"/PlaybackInfo?UserId="+settings.userid+"&StartTimeTicks=0&IsPlayback=true&AutoOpenLiveStream=true&MaxStreamingBitrate=140000000&EnableDirectStream=true" , {
method: "POST",
headers: this.headers(),
data: settings.data,
success: function(data) {
settings.success(data);
},
error: settings.error
});

};

EMBY.prototype.postActiveEncodingStop = function(settings) {
ajax.request(this.settings.ServerUrl + "/Videos/ActiveEncodings?DeviceId=" + device.id , {
method: "DELETE",
Expand Down
1 change: 1 addition & 0 deletions script/models/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ Collection.prototype.load = function(data, backstate, settings) {
event.preventDefault()
prefs.lastItemIndex = event.delegateTarget.dataset.index;
prefs.lastItemPosition = document.getElementById("view").scrollLeft;
prefs.isLiveTvItem = false;
dom.dispatchCustonEvent(document, "mediaItemSelected", event.delegateTarget.dataset);
});

Expand Down
Loading

0 comments on commit bd85660

Please sign in to comment.