Skip to content

Commit 37a88dc

Browse files
committed
code clean-ups and smaller tweaks
1 parent f3158dc commit 37a88dc

File tree

4 files changed

+64
-39
lines changed

4 files changed

+64
-39
lines changed

www/css/sepiaFW-style.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ body.limit-size {
115115
overflow: hidden;
116116
z-index: 50;
117117
border: 0px solid black;
118+
-webkit-touch-callout: none !important;
119+
-webkit-user-select: none;
120+
user-select: none;
118121
}
119122
.sepiaFW-swipeBar-switchable {
120123
background: transparent;
@@ -123,6 +126,9 @@ body.limit-size {
123126
margin: 0px;
124127
padding: 0px;
125128
border: 0px solid black;
129+
-webkit-touch-callout: none !important;
130+
-webkit-user-select: none;
131+
user-select: none;
126132
}
127133
.sepiaFW-fullSize {
128134
width: 100% !important;
@@ -1588,6 +1594,9 @@ html.dark-skin #sepiaFW-login-help-btn {
15881594
padding-right: 0px !important;
15891595
width: 100%;
15901596
height: 100%;
1597+
-webkit-touch-callout: none !important;
1598+
-webkit-user-select: none;
1599+
user-select: none;
15911600
}
15921601
#sepiaFW-chat-send i {
15931602
transform: rotate(180deg);
@@ -1739,7 +1748,10 @@ html.dark-skin #sepiaFW-login-help-btn {
17391748
overflow: visible;
17401749
display: flex;
17411750
align-items: center;
1742-
justify-content: center;
1751+
justify-content: center;
1752+
-webkit-touch-callout: none !important;
1753+
-webkit-user-select: none;
1754+
user-select: none;
17431755
}
17441756
#sepiaFW-assist-btn-area button {
17451757
border-radius: 23px;
@@ -1748,6 +1760,9 @@ html.dark-skin #sepiaFW-login-help-btn {
17481760
padding: 0px;
17491761
width: 37px;
17501762
height: 37px;
1763+
-webkit-touch-callout: none !important;
1764+
-webkit-user-select: none;
1765+
user-select: none;
17511766
}
17521767
#sepiaFW-assist-btn-orbiters {
17531768
position: absolute;

www/scripts/sepiaFW.audio.js

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ function sepiaFW_build_audio(){
321321
//---- broadcasting -----
322322

323323
AudioPlayer.broadcastAudioEvent = function(source, action, playerObject){
324-
//stream, effects, tts-player, unknown - start, stop, error, fadeOut, fadeIn
324+
//stream, effects, tts-player, unknown - prepare, start, stop, error, fadeOut, fadeIn
325325
//android-intent - stop, start
326326
//youtube-embedded - start, resume, pause, hold
327327
source = source.toLowerCase();
@@ -333,7 +333,7 @@ function sepiaFW_build_audio(){
333333
source: source,
334334
action: action
335335
}});
336-
document.dispatchEvent(event);
336+
document.dispatchEvent(event); //NOTE: we could check result for 'prevent default' (its sync.)
337337
//console.error("audio event: " + source + " - " + action);
338338
}
339339

@@ -832,11 +832,13 @@ function sepiaFW_build_audio(){
832832
}else if (audioPlayer === 'tts'){
833833
audioPlayer = speaker;
834834
}
835-
if (audioURL) audioURL = SepiaFW.config.replacePathTagWithActualPath(audioURL);
836-
835+
var sourceName = "unknown";
837836
var audioOnEndFired = false; //prevent doublefireing of audio onend onpause
838837

838+
if (audioURL) audioURL = SepiaFW.config.replacePathTagWithActualPath(audioURL);
839+
839840
if (audioPlayer == player){
841+
sourceName = "stream";
840842
if (audioURL){
841843
beforeLastAudioStream = lastAudioStream;
842844
lastAudioStream = audioURL;
@@ -857,9 +859,11 @@ function sepiaFW_build_audio(){
857859
Stream.isLoading = true;
858860

859861
}else if (audioPlayer == player2){
862+
sourceName = "effects";
860863
//TODO: ?
861864

862865
}else if (audioPlayer == speaker){
866+
sourceName = "tts-player";
863867
if (isVoiceEffectSetupPending){
864868
//TODO: delay
865869
SepiaFW.debug.error("AUDIO: voice-effects setup still pending! Should delay 'AudioPlayer.playURL'"); //debug
@@ -878,6 +882,7 @@ function sepiaFW_build_audio(){
878882
}
879883

880884
audioPlayer.preload = 'auto';
885+
AudioPlayer.broadcastAudioEvent(sourceName, "prepare", audioPlayer);
881886

882887
//console.log("Audio-URL: " + audioURL); //DEBUG
883888
audioPlayer.src = audioURL;
@@ -898,15 +903,7 @@ function sepiaFW_build_audio(){
898903
}
899904
//callback
900905
if (onStartCallback) onStartCallback();
901-
if (audioPlayer == player){
902-
AudioPlayer.broadcastAudioEvent("stream", "start", audioPlayer);
903-
}else if (audioPlayer == player2){
904-
AudioPlayer.broadcastAudioEvent("effects", "start", audioPlayer);
905-
}else if (audioPlayer == speaker){
906-
AudioPlayer.broadcastAudioEvent("tts-player", "start", audioPlayer);
907-
}else{
908-
AudioPlayer.broadcastAudioEvent("unknown", "start", audioPlayer);
909-
}
906+
AudioPlayer.broadcastAudioEvent(sourceName, "start", audioPlayer);
910907
};
911908
audioPlayer.onpause = function(){
912909
if (!audioOnEndFired){
@@ -926,15 +923,15 @@ function sepiaFW_build_audio(){
926923
}
927924
//callback
928925
if (onEndCallback) onEndCallback();
926+
var sourceName = "unknown";
929927
if (audioPlayer == player){
930-
AudioPlayer.broadcastAudioEvent("stream", "stop", audioPlayer);
928+
sourceName = "stream";
931929
}else if (audioPlayer == player2){
932-
AudioPlayer.broadcastAudioEvent("effects", "stop", audioPlayer);
930+
sourceName = "effects";
933931
}else if (audioPlayer == speaker){
934-
AudioPlayer.broadcastAudioEvent("tts-player", "stop", audioPlayer);
935-
}else{
936-
AudioPlayer.broadcastAudioEvent("unknown", "stop", audioPlayer);
932+
sourceName = "tts-player";
937933
}
934+
AudioPlayer.broadcastAudioEvent(sourceName, "stop", audioPlayer);
938935
}
939936
};
940937
audioPlayer.onended = function(){
@@ -966,15 +963,15 @@ function sepiaFW_build_audio(){
966963
}
967964
//callback
968965
if (onErrorCallback) onErrorCallback();
966+
var sourceName = "unknown";
969967
if (audioPlayer == player){
970-
AudioPlayer.broadcastAudioEvent("stream", "error", audioPlayer);
968+
sourceName = "stream";
971969
}else if (audioPlayer == player2){
972-
AudioPlayer.broadcastAudioEvent("effects", "error", audioPlayer);
970+
sourceName = "effects";
973971
}else if (audioPlayer == speaker){
974-
AudioPlayer.broadcastAudioEvent("tts-player", "error", audioPlayer);
975-
}else{
976-
AudioPlayer.broadcastAudioEvent("unknown", "error", audioPlayer);
972+
sourceName = "tts-player";
977973
}
974+
AudioPlayer.broadcastAudioEvent(sourceName, "error", audioPlayer);
978975
};
979976
var p = audioPlayer.play();
980977
if (p && ('catch' in p)){
@@ -1046,6 +1043,7 @@ function sepiaFW_build_audio(){
10461043
}
10471044

10481045
var audioOnEndFired = false;
1046+
AudioPlayer.broadcastAudioEvent("effects", "prepare", audioPlayer);
10491047

10501048
audioPlayer.src = alarmSound;
10511049
audioPlayer.preload = 'auto';

www/scripts/sepiaFW.ui.build.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ function sepiaFW_build_ui_build(sepiaSessionId){
320320
$('#sepiaFW-chat-input').val('');
321321
},'',function(){
322322
//short press - send action
323-
if (SepiaFW.speech && SepiaFW.speech.isRecognizing()){
323+
if (SepiaFW.speech.isRecognizing()){
324324
SepiaFW.speech.stopRecognition();
325325
}else{
326-
if (SepiaFW.audio && SepiaFW.audio.initAudio(SepiaFW.client.sendInputText)){
326+
if (SepiaFW.audio.initAudio(SepiaFW.client.sendInputText)){
327327
//skip because of callback
328328
}else{
329329
SepiaFW.client.sendInputText();
@@ -421,7 +421,7 @@ function sepiaFW_build_ui_build(sepiaSessionId){
421421
//long-press
422422
},'',function(){
423423
//short press - send action
424-
if (SepiaFW.speech && SepiaFW.speech.isRecognizing()){
424+
if (SepiaFW.speech.isRecognizing()){
425425
SepiaFW.speech.stopRecognition();
426426
}else{
427427
var bubble = document.getElementById("sepiaFW-chat-controls-speech-box-bubble");

www/scripts/sepiaFW.wakeWordSettings.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ function sepiaFW_build_wake_word_settings() {
9292
}else if (eventName == "audioend"){
9393
//anything?
9494
}
95+
setTimeout(function(){ checkButtonState(); }, 1000);
9596
}
9697

9798
WakeWordSettings.debugLog = function(info, isError){
@@ -259,9 +260,11 @@ function sepiaFW_build_wake_word_settings() {
259260
function(){
260261
debugInfo = true;
261262
$('.sepiaFW-wake-word-settings-page .debug-setting').show(300); //ww debug settings
263+
checkButtonState();
262264
},function(){
263265
debugInfo = false;
264266
$('.sepiaFW-wake-word-settings-page .debug-setting').hide(150);
267+
checkButtonState();
265268
}, debugInfo)
266269
);
267270

@@ -323,6 +326,12 @@ function sepiaFW_build_wake_word_settings() {
323326
//ON-OPEN
324327
function onFrameOpen(){
325328
WakeWordSettings.isOpen = true;
329+
debugInfo = document.getElementById("sepiaFW-menu-toggle-wake-word-debug").getValue();
330+
331+
//stop running audio?
332+
if (SepiaFW.audio.isAnyAudioSourceActive() && !SepiaFW.wakeTriggers.allowWakeWordDuringStream){
333+
SepiaFW.audio.stop();
334+
}
326335

327336
//Wake-word listener for testing
328337
document.addEventListener("sepia_wake_word", wakeWordTest);
@@ -337,18 +346,7 @@ function sepiaFW_build_wake_word_settings() {
337346
sensitivityEle.title = SepiaFW.wakeTriggers.getWakeWordSensitivities();
338347

339348
//check button states
340-
if (SepiaFW.wakeTriggers.engineLoaded){
341-
isListening = SepiaFW.wakeTriggers.isListening();
342-
if (isListening){
343-
document.getElementById('sepiaFW-wake-word-toggle').innerHTML = "STOP";
344-
}else{
345-
document.getElementById('sepiaFW-wake-word-toggle').innerHTML = "START";
346-
}
347-
$('#sepiaFW-wake-word-engine-reset').show();
348-
}else{
349-
isListening = false;
350-
document.getElementById('sepiaFW-wake-word-toggle').innerHTML = "LOAD";
351-
}
349+
checkButtonState();
352350

353351
//Show active wake-word
354352
$("#sepiaFW-wake-word-version").val(SepiaFW.wakeTriggers.getWakeWordVersion());
@@ -369,6 +367,20 @@ function sepiaFW_build_wake_word_settings() {
369367
WakeWordSettings.debugLog("UPDATED " + info);
370368
}
371369
}
370+
function checkButtonState(){
371+
if (SepiaFW.wakeTriggers.engineLoaded){
372+
isListening = SepiaFW.wakeTriggers.isListening();
373+
if (isListening){
374+
document.getElementById('sepiaFW-wake-word-toggle').innerHTML = "STOP";
375+
}else{
376+
document.getElementById('sepiaFW-wake-word-toggle').innerHTML = "START";
377+
}
378+
$('#sepiaFW-wake-word-engine-reset').show();
379+
}else{
380+
isListening = false;
381+
document.getElementById('sepiaFW-wake-word-toggle').innerHTML = "LOAD";
382+
}
383+
}
372384

373385
//ON-CLOSE
374386
function onFrameClose(){

0 commit comments

Comments
 (0)