Skip to content

Commit

Permalink
#1471: show speaker status
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@18737 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 16, 2018
1 parent 4ec1dbf commit 4af39ff
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/html5/css/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ div.windowinfocus {
color: #fff;
}

.audio {
float: right;
padding-right: 10px;
}

@media screen {
.notifications .alert.visible {
margin-top: 0;
Expand Down
Binary file added src/html5/icons/speaker-buffering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/html5/icons/speaker-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/html5/icons/speaker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
<div class="clock_block">
<p id="clock_text"></p>
</div>
<div class="audio">
<div id="speaker">
<img id="speaker_icon" src="./icons/speaker-off.png" alt="speaker off" />
</div>
</div>
</div>
</div>

Expand Down Expand Up @@ -596,6 +601,25 @@ <h3>Version 2.3</h3>
if (getboolparam("clock")) {
init_clock(client);
}
client.on_audio_state_change = function(newstate, details) {
var tooltip = "";
var image_name = "";
if (newstate=="playing") {
image_name = "speaker.png";
tooltip = details || "playing";
}
else if (newstate=="waiting") {
image_name = "speaker-buffering.png";
tooltip = details || "buffering";
}
else {
image_name = "speaker-off.png";
tooltip = details || "off";
}
clog("audio-state:", newstate);
$("#speaker_icon").attr("src", "./icons/"+image_name);
$("#speaker_icon").attr("title", tooltip);
};
document.addEventListener("visibilitychange", function (e) {
window_ids = Object.keys(client.id_to_window);
clog("visibilitychange hidden=", document.hidden);
Expand Down
6 changes: 6 additions & 0 deletions src/html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2258,18 +2258,23 @@ XpraClient.prototype._process_sound_data = function(packet, ctx) {
ctx.add_sound_data(codec, buf, metadata);
}
catch(e) {
this.on_audio_state_change("error", ""+e);
this.error("audio failed:", e);
this.close_audio();
}
}

XpraClient.prototype.on_audio_state_change = function(newstate, details) {
//can be overriden
}

XpraClient.prototype.add_sound_data = function(codec, buf, metadata) {
var MIN_START_BUFFERS = 4;
var MAX_BUFFERS = 250;
this.debug("audio", "sound-data: ", codec, ", ", buf.length, "bytes");
if (this.audio_buffers.length>=MAX_BUFFERS) {
this.warn("audio queue overflowing: "+this.audio_buffers.length+", stopping");
this.on_audio_state_change("error", "queue overflow");
this.close_audio();
return;
}
Expand Down Expand Up @@ -2322,6 +2327,7 @@ XpraClient.prototype._audio_start_stream = function() {
else {
this.audio_aurora_ctx.play();
}
this.on_audio_state_change("playing", ""+this.audio_framework+" playing "+this.audio_codec+" stream");
}

XpraClient.prototype._audio_ready = function() {
Expand Down
Binary file added src/icons/speaker-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4af39ff

Please sign in to comment.