Skip to content

Commit 6135b82

Browse files
add more control buttons to web ui
1 parent a00294d commit 6135b82

File tree

6 files changed

+94
-2
lines changed

6 files changed

+94
-2
lines changed

kawaii_player/media_server.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,15 @@ def process_POST(self):
835835
param, value = value, param
836836
self.final_message(bytes('Command Recieved', 'utf-8'))
837837
ui.gui_signals.player_command(param.replace('+', ' '), value.replace('+', ' '))
838+
elif self.path.startswith('/sending_web_command'):
839+
content = self.rfile.read(int(self.headers['Content-Length']))
840+
if isinstance(content, bytes):
841+
content = str(content, 'utf-8')
842+
content = json.loads(content)
843+
param = "param={}".format(content.get("param"))
844+
value = "widget={}".format(content.get("widget"))
845+
self.final_message(bytes('Command Recieved', 'utf-8'))
846+
ui.gui_signals.player_command(param.replace('+', ' '), value.replace('+', ' '))
838847
else:
839848
self.final_message(bytes('Nothing Available', 'utf-8'))
840849

@@ -2078,6 +2087,7 @@ def get_the_content(self, path, get_bytes, my_ip_addr=None, play_id=None):
20782087
else:
20792088
ui.web_control = 'master'
20802089
self.final_message(bytes(ui.web_control, 'utf-8'))
2090+
ui.frame_extra_toolbar.master_slave_tab_btn.clicked_emit()
20812091
if not ui.settings_box.tabs_present:
20822092
ui.gui_signals.box_settings('hide')
20832093
else:

kawaii_player/settings_widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def slave_commands(self, cmd=None, data=None):
700700
netloc = n.netloc
701701
val = ui.vnt.cookie_session.get(netloc)
702702
verify = ui.list2.verify_slave_ssl
703-
print(addr, ip, request_url, netloc, val, verify, cmd)
703+
print(addr, ip, request_url, netloc, val, verify, cmd, data)
704704
logger.debug('url={} verify={}'.format(addr, verify))
705705
if val:
706706
if cmd in ['remote_on.htm', 'remote_off.htm', 'lock']:

kawaii_player/web/myscript.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,53 @@ function toggle_audio_player(){
11431143
})
11441144
}
11451145

1146+
function goto_previous_chapter(){
1147+
var client = new postRequest();
1148+
let data = {'param': 'click', 'widget': 'btn_chapter_minus'};
1149+
client.post('sending_web_command', data, function(response) {
1150+
console.log(response);
1151+
})
1152+
}
1153+
1154+
function toggle_fullscreen_window(){
1155+
var client = new postRequest();
1156+
let data = {'param': 'click', 'widget': 'btn_fs_window'};
1157+
client.post('sending_web_command', data, function(response) {
1158+
console.log(response);
1159+
})
1160+
}
1161+
1162+
function show_video_stats(){
1163+
var client = new postRequest();
1164+
let data = {'param': 'click', 'widget': 'btn_show_stat'};
1165+
client.post('sending_web_command', data, function(response) {
1166+
console.log(response);
1167+
})
1168+
}
1169+
1170+
function show_video_stats(){
1171+
var client = new postRequest();
1172+
let data = {'param': 'click', 'widget': 'btn_show_stat'};
1173+
client.post('sending_web_command', data, function(response) {
1174+
console.log(response);
1175+
})
1176+
}
1177+
1178+
function change_aspect_ratio(){
1179+
let aspect_ratio = document.getElementById("aspect_ratio").value;
1180+
if(aspect_ratio == ""){
1181+
console.log("no aspect ratio selected");
1182+
}else{
1183+
var client = new postRequest();
1184+
let data = {'param': 'click', 'widget': aspect_ratio};
1185+
client.post('sending_web_command', data, function(response) {
1186+
console.log(response);
1187+
})
1188+
}
1189+
}
1190+
1191+
1192+
11461193
function optChange(){
11471194
var x = document.getElementById("opt").value.toLowerCase();
11481195
x = x.replace(/" "/g,"+");

kawaii_player/web/playlist.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@
6666
<button id="fullscreen" title="Toggle Fullscreen">F</button>
6767
<button id="toggle_audio" title="Toggle Audio" onclick="toggle_audio_player()">Audio</button>
6868
<button id="toggle_subtitle" title="Toggle Subtitle" onclick="toggle_subtitle_player()">Sub</button>
69+
<button id="prev_chapter" title="Prev Chapter" onclick="goto_previous_chapter()">Chapter-</button>
70+
<button id="next_chapter" title="Next Chapter-" onclick="goto_next_chapter()">Chapter+</button>
71+
<button id="toggle_fullscreen_window" title="Toggle Fullscreen Window" onclick="toggle_fullscreen_window()">FS</button>
72+
<button id="show_stats" title="Video Stats" onclick="show_video_stats()">Stats</button>
73+
<div id="aspect_selection" class="select_aspect_ratio">
74+
<select id="aspect_ratio" onchange="change_aspect_ratio()">
75+
<option value="">Aspect Ratio</option>
76+
<option value="btn_aspect_original">Original</option>
77+
<option value="btn_aspect_disable">Disable</option>
78+
<option value="btn_aspect_4_3">4:3</option>
79+
<option value="btn_aspect_16_9">16:9</option>
80+
<option value="btn_aspect_235">2.35:1</option>
81+
</select>
82+
</div>
6983
<button id="show_player" title="Show Player" onclick="show_player_window()">Show</button>
7084
<button id="hide_player" title="Hide Player" onclick="hide_player_window()">Hide</button>
7185
<button id="toggle_master" title="Toggle Master" onclick="toggle_master_slave()">Master</button>

kawaii_player/web/style.css

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,24 @@ height: 12px;
434434
color: black;
435435
}
436436

437+
.select_aspect_ratio select{
438+
439+
background-color: white;
440+
border: none;
441+
color: black;
442+
padding:7px;
443+
text-decoration: none;
444+
float:left;
445+
width: 25%;
446+
height: 64px;
447+
max-width: 100%;
448+
text-align: center;
449+
}
450+
451+
.select_aspect_ratio select:hover{
452+
background-color: #aab7b8;
453+
color: black;
454+
}
437455
.site_selection button{
438456
background-color: white;
439457
border: none;
@@ -581,7 +599,8 @@ height: 12px;
581599
/*width:86px;*/
582600
display: grid;
583601
width: 25%;
584-
height: 32px;
602+
height: 64px;
603+
line-height: 48px;
585604
/*grid-template-columns: repeat(auto-fill, minmax(32px, 86px));*/
586605
}
587606

kawaii_player/widgets/optionwidgets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,13 +1676,15 @@ def __init__(self, parent, uiwidget):
16761676
def toggle_master_slave(self):
16771677
txt = self.master_slave_tab_btn.text()
16781678
if txt.lower() == 'master':
1679+
ui.web_control = "slave"
16791680
self.master_slave_tab_btn.setText('Slave')
16801681
ui.extra_toolbar_control = 'slave'
16811682
if not ui.settings_box.tabs_present:
16821683
ui.gui_signals.box_settings('hide')
16831684
else:
16841685
self.master_slave_tab_btn.setText('Master')
16851686
ui.extra_toolbar_control = 'master'
1687+
ui.web_control = "master"
16861688

16871689
def generate_subtitle_frame(self):
16881690
try:

0 commit comments

Comments
 (0)