Skip to content
Permalink
Browse files

stream config almost completed

  • Loading branch information...
jankammerath committed Jan 21, 2018
1 parent 22a1ad0 commit 6518263872cc71d8b0f195b756aab56800fb6061
Showing with 189 additions and 3 deletions.
  1. +3 −2 app/app.html
  2. +38 −0 app/css/style.css
  3. +1 −1 app/js/epg.js
  4. +30 −0 app/js/player.js
  5. +117 −0 app/js/streamconfig.js
  6. BIN img/programme-info.png
@@ -31,6 +31,7 @@
<!-- standard components -->
<div id="list" class="component"></div>
<div id="epg" class="component"></div>
<div id="streamconfig" class="component"></div>

<!-- control component -->
<div id="control" class="component">
@@ -46,9 +47,9 @@

<div class="channelinfo">
<div class="channelname"></div>
<div class="channelformat"></div>
<div class="channelresolution"></div>
<div class="channeldatarate"></div>
<div class="channelformat"></div>
</div>

<div class="programmetitle"></div>
@@ -71,7 +72,7 @@
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript">
$(document).ready(function(){
app.init(["player", "epg", "list", "control"]);
app.init(["player", "epg", "list", "control", "streamconfig"]);
});
</script>
</body>
@@ -246,6 +246,44 @@ body{
opacity:0.7;
}

/* stream config styles */
#streamconfig{
right:10px;
width:220px;
}

#streamconfig .track{
padding:5px;
margin:5px;
padding-left:30px;
background-repeat:no-repeat;
background-size:20px auto;
border-radius:5px;
opacity:0.5;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

#streamconfig .track[data-active='true']{
opacity:0.9;
}

#streamconfig .track[data-selected='true']{
opacity:0.9;
background-color:#434177;
}

#streamconfig .track[data-tracktype='audio']{
background-image:url('../img/audio.svg');
background-position:5px 4px;
}

#streamconfig .track[data-tracktype='subtitle']{
background-image:url('../img/subtitle.svg');
background-position:5px 8px;
}

/* custom webkit scrollbar */
::-webkit-scrollbar {
width: 8px;
@@ -17,5 +17,5 @@
*/

var epg = {
toggleKey: 9 /* TAB */
toggleKey: 113 /* F2 */
}
@@ -118,6 +118,36 @@ var player = {
return result;
},

getSubtitleList: function(){
if(player.isReady()){
return iptvx.subtitleList;
}else{
return [];
}
},

getAudioList: function(){
if(player.isReady()){
return iptvx.trackList;
}else{
return [];
}
},

/*
Sets the audio track by its id
*/
setAudioTrack: function(trackId){
player.execute("set-audiotrack " + trackId);
},

/*
Sets the subtitle track by its id
*/
setSubtitleTrack: function(trackId){
player.execute("set-subtitle " + trackId);
},

/*
Checks if the player instance is ready
*/
@@ -0,0 +1,117 @@
/*
Copyright 2018 Jan Kammerath
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

var streamconfig = {
selectedTrack: 0,
trackCount: 0,
toggleKey: 9, /* TAB */

init: function(){
/* start the update interval to monitor
the stream and its available tracks */
setInterval(streamconfig.update,3000);
},

/*
Updates the stream configuration
*/
update: function(){
var html = "";
var trackNum = 0;

/* render audio tracks first */
var audioList = player.getAudioList();
for(var a=0; a<audioList.length; a++){
html += "<div class=\"track\" "
+ "data-tracktype=\"audio\" ";

if(audioList[a].active){
html += "data-active=\"true\" "
}else{
html += "data-active=\"false\" "
}

if(streamconfig.selectedTrack == trackNum){
html += "data-selected=\"true\" "
}else{
html += "data-selected=\"false\" "
}

html += "data-trackid=\"" + audioList[a].id + "\">"
+ audioList[a].name
+ "</div>";

trackNum++;
}

/* next up render subtitle tracks */
var subtitleList = player.getSubtitleList();
for(var s=0; s<subtitleList.length; s++){
html += "<div class=\"track\" "
+ "data-tracktype=\"subtitle\" "

if(subtitleList[s].active){
html += "data-active=\"true\" "
}else{
html += "data-active=\"false\" "
}

if(streamconfig.selectedTrack == trackNum){
html += "data-selected=\"true\" "
}else{
html += "data-selected=\"false\" "
}

html += "data-trackid=\"" + subtitleList[s].id + "\">"
+ subtitleList[s].name
+ "</div>";

trackNum++;
}

/* update track count */
streamconfig.trackCount = trackNum;

/* flush html to component */
$("#streamconfig").html(html);
},

handleKey: function(keyCode){
if(keyCode == 38){
/* KEY UP */
if(streamconfig.selectedTrack == 0){
streamconfig.selectedTrack = (streamconfig.trackCount-1);
}else{
streamconfig.selectedTrack--;
}

streamconfig.update();
}if(keyCode == 40){
/* KEY DOWN */
if(streamconfig.selectedTrack == (streamconfig.trackCount-1)){
streamconfig.selectedTrack = 0;
}else{
streamconfig.selectedTrack++;
}

streamconfig.update();
}if(keyCode == 13){
/* RETURN KEY */
}
}
}
BIN +393 KB (170%) img/programme-info.png
Binary file not shown.

0 comments on commit 6518263

Please sign in to comment.
You can’t perform that action at this time.