From 698db2a95c7001a36ce8f71e4ffdaa21b47168eb Mon Sep 17 00:00:00 2001 From: Vincent Pizzo Date: Thu, 24 Jul 2014 08:35:09 -0500 Subject: [PATCH 001/126] If possible, support audio content types Adding support for HTML5 audio playback if the browser supports both the audio HTML5 element and the content type. --- src/main/coffeescript/view/OperationView.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/coffeescript/view/OperationView.coffee b/src/main/coffeescript/view/OperationView.coffee index 908d0f39650..69106e1dea3 100644 --- a/src/main/coffeescript/view/OperationView.coffee +++ b/src/main/coffeescript/view/OperationView.coffee @@ -337,6 +337,10 @@ class OperationView extends Backbone.View # if server is nice, and sends content-type back, we can use it contentType = if headers && headers["Content-Type"] then headers["Content-Type"].split(";")[0].trim() else null + + supportsAudioPlayback = (contentType) -> + audioElement = document.createElement('audio') + return !!(audioElement.canPlayType && audioElement.canPlayType(contentType).replace(/no/, '')) if !content code = $('').text("no content") @@ -352,6 +356,8 @@ class OperationView extends Backbone.View pre = $('
').append(code)
     else if /^image\//.test(contentType)
       pre = $('').attr('src',url)
+    else if /^audio\//.test(contentType) and supportsAudioPlayback(contentType)
+      pre = $('