summaryrefslogtreecommitdiff
path: root/htroot/js/yacysearch.js
diff options
context:
space:
mode:
authorluccioman <luccioman@users.noreply.github.com>2018-02-23 11:41:50 +0100
committerluccioman <luccioman@users.noreply.github.com>2018-02-23 11:41:50 +0100
commit07e86288534b7f19f8a0216138adc499ee15c6c6 (patch)
treec197c590d86605691878ae480597de59b10d8204 /htroot/js/yacysearch.js
parent1b90479a7644674fcb2e76bc76dcadc73fe09dad (diff)
Added HTML5 embedded audio for results playing on supporting browsers
Restricted to authenticated or localhost users only to prevent redistribution license issues.
Diffstat (limited to 'htroot/js/yacysearch.js')
-rw-r--r--htroot/js/yacysearch.js44
1 files changed, 43 insertions, 1 deletions
diff --git a/htroot/js/yacysearch.js b/htroot/js/yacysearch.js
index f9927f3bd..16b80ff15 100644
--- a/htroot/js/yacysearch.js
+++ b/htroot/js/yacysearch.js
@@ -284,5 +284,47 @@ function toggleMoreTags(button, moreTagsId) {
moreTagsContainer.className = "";
}
}
-
+}
+
+/**
+ * Handle embedded audio result load error.
+ *
+ * @param event
+ * {ErrorEvent} the error event triggered
+ */
+function handleAudioLoadError(event) {
+ if (event != null && event.target != null) {
+ /* Fill the title attribute to provide some feedback about the error without need for looking at the console */
+ if (event.target.error != null && event.target.error.message) {
+ event.target.title = "Cannot play ("
+ + event.target.error.message + ")";
+ } else {
+ event.target.title = "Cannot play";
+ }
+
+ /* Apply CSS class marking error for visual feedback*/
+ event.target.className = "audioError";
+ }
+}
+
+/**
+ * Handle embedded audio result 'playing' event : pauses any other currently
+ * playing audio.
+ *
+ * @param event
+ * {Event} a 'playing' event
+ */
+function handleAudioPlaying(event) {
+ if (event != null && event.target != null) {
+ var audioElems = document.getElementsByTagName("audio");
+ if(audioElems != null) {
+ for (var i = 0; i < audioElems.length; i++) {
+ var audioElem = audioElems[i];
+ if (audioElem != event.target && audioElem.pause
+ && !audioElem.paused) {
+ audioElem.pause();
+ }
+ }
+ }
+ }
} \ No newline at end of file