Skip to content

Commit

Permalink
add more control buttons to web ui
Browse files Browse the repository at this point in the history
  • Loading branch information
kanishka-linux committed Jan 30, 2021
1 parent a00294d commit 6135b82
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 2 deletions.
10 changes: 10 additions & 0 deletions kawaii_player/media_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,15 @@ def process_POST(self):
param, value = value, param
self.final_message(bytes('Command Recieved', 'utf-8'))
ui.gui_signals.player_command(param.replace('+', ' '), value.replace('+', ' '))
elif self.path.startswith('/sending_web_command'):
content = self.rfile.read(int(self.headers['Content-Length']))
if isinstance(content, bytes):
content = str(content, 'utf-8')
content = json.loads(content)
param = "param={}".format(content.get("param"))
value = "widget={}".format(content.get("widget"))
self.final_message(bytes('Command Recieved', 'utf-8'))
ui.gui_signals.player_command(param.replace('+', ' '), value.replace('+', ' '))
else:
self.final_message(bytes('Nothing Available', 'utf-8'))

Expand Down Expand Up @@ -2078,6 +2087,7 @@ def get_the_content(self, path, get_bytes, my_ip_addr=None, play_id=None):
else:
ui.web_control = 'master'
self.final_message(bytes(ui.web_control, 'utf-8'))
ui.frame_extra_toolbar.master_slave_tab_btn.clicked_emit()
if not ui.settings_box.tabs_present:
ui.gui_signals.box_settings('hide')
else:
Expand Down
2 changes: 1 addition & 1 deletion kawaii_player/settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def slave_commands(self, cmd=None, data=None):
netloc = n.netloc
val = ui.vnt.cookie_session.get(netloc)
verify = ui.list2.verify_slave_ssl
print(addr, ip, request_url, netloc, val, verify, cmd)
print(addr, ip, request_url, netloc, val, verify, cmd, data)
logger.debug('url={} verify={}'.format(addr, verify))
if val:
if cmd in ['remote_on.htm', 'remote_off.htm', 'lock']:
Expand Down
47 changes: 47 additions & 0 deletions kawaii_player/web/myscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,53 @@ function toggle_audio_player(){
})
}

function goto_previous_chapter(){
var client = new postRequest();
let data = {'param': 'click', 'widget': 'btn_chapter_minus'};
client.post('sending_web_command', data, function(response) {
console.log(response);
})
}

function toggle_fullscreen_window(){
var client = new postRequest();
let data = {'param': 'click', 'widget': 'btn_fs_window'};
client.post('sending_web_command', data, function(response) {
console.log(response);
})
}

function show_video_stats(){
var client = new postRequest();
let data = {'param': 'click', 'widget': 'btn_show_stat'};
client.post('sending_web_command', data, function(response) {
console.log(response);
})
}

function show_video_stats(){
var client = new postRequest();
let data = {'param': 'click', 'widget': 'btn_show_stat'};
client.post('sending_web_command', data, function(response) {
console.log(response);
})
}

function change_aspect_ratio(){
let aspect_ratio = document.getElementById("aspect_ratio").value;
if(aspect_ratio == ""){
console.log("no aspect ratio selected");
}else{
var client = new postRequest();
let data = {'param': 'click', 'widget': aspect_ratio};
client.post('sending_web_command', data, function(response) {
console.log(response);
})
}
}



function optChange(){
var x = document.getElementById("opt").value.toLowerCase();
x = x.replace(/" "/g,"+");
Expand Down
14 changes: 14 additions & 0 deletions kawaii_player/web/playlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@
<button id="fullscreen" title="Toggle Fullscreen">F</button>
<button id="toggle_audio" title="Toggle Audio" onclick="toggle_audio_player()">Audio</button>
<button id="toggle_subtitle" title="Toggle Subtitle" onclick="toggle_subtitle_player()">Sub</button>
<button id="prev_chapter" title="Prev Chapter" onclick="goto_previous_chapter()">Chapter-</button>
<button id="next_chapter" title="Next Chapter-" onclick="goto_next_chapter()">Chapter+</button>
<button id="toggle_fullscreen_window" title="Toggle Fullscreen Window" onclick="toggle_fullscreen_window()">FS</button>
<button id="show_stats" title="Video Stats" onclick="show_video_stats()">Stats</button>
<div id="aspect_selection" class="select_aspect_ratio">
<select id="aspect_ratio" onchange="change_aspect_ratio()">
<option value="">Aspect Ratio</option>
<option value="btn_aspect_original">Original</option>
<option value="btn_aspect_disable">Disable</option>
<option value="btn_aspect_4_3">4:3</option>
<option value="btn_aspect_16_9">16:9</option>
<option value="btn_aspect_235">2.35:1</option>
</select>
</div>
<button id="show_player" title="Show Player" onclick="show_player_window()">Show</button>
<button id="hide_player" title="Hide Player" onclick="hide_player_window()">Hide</button>
<button id="toggle_master" title="Toggle Master" onclick="toggle_master_slave()">Master</button>
Expand Down
21 changes: 20 additions & 1 deletion kawaii_player/web/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,24 @@ height: 12px;
color: black;
}

.select_aspect_ratio select{

background-color: white;
border: none;
color: black;
padding:7px;
text-decoration: none;
float:left;
width: 25%;
height: 64px;
max-width: 100%;
text-align: center;
}

.select_aspect_ratio select:hover{
background-color: #aab7b8;
color: black;
}
.site_selection button{
background-color: white;
border: none;
Expand Down Expand Up @@ -581,7 +599,8 @@ height: 12px;
/*width:86px;*/
display: grid;
width: 25%;
height: 32px;
height: 64px;
line-height: 48px;
/*grid-template-columns: repeat(auto-fill, minmax(32px, 86px));*/
}

Expand Down
2 changes: 2 additions & 0 deletions kawaii_player/widgets/optionwidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1676,13 +1676,15 @@ def __init__(self, parent, uiwidget):
def toggle_master_slave(self):
txt = self.master_slave_tab_btn.text()
if txt.lower() == 'master':
ui.web_control = "slave"
self.master_slave_tab_btn.setText('Slave')
ui.extra_toolbar_control = 'slave'
if not ui.settings_box.tabs_present:
ui.gui_signals.box_settings('hide')
else:
self.master_slave_tab_btn.setText('Master')
ui.extra_toolbar_control = 'master'
ui.web_control = "master"

def generate_subtitle_frame(self):
try:
Expand Down

0 comments on commit 6135b82

Please sign in to comment.