Fix audio player in IE8 (but may still be blocked depending on security settings)
authorstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Wed, 13 Feb 2013 05:43:05 +0000 (05:43 +0000)
committerstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Wed, 13 Feb 2013 05:43:05 +0000 (05:43 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/sr_freecap/trunk@71164 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
Resources/Public/JavaScript/freeCap.js

index 2888add..1cc9670 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
        * Cleanup audio file rendering
        * Fix audio player in IE7, IE9 and Opera
+       * Fix audio player in IE8 (but may still be blocked depending on security settings)
 
 2013-02-11  Stanislas Rolland  <typo3@sjbr.ca>
 
index 9cbd960..5fe5b5c 100644 (file)
                                var audioElement = document.createElement('audio');
                                if (audioElement.canPlayType && (audioElement.canPlayType('audio/x-wav') === 'maybe' || audioElement.canPlayType('audio/x-wav') === 'probably') && !window.opera) {
                                        audioElement.setAttribute('id', 'tx_srfreecap_captcha_playAudio_audio' + id);
-                                       audioElement.setAttribute('autoplay', 'autoplay');
                                        audioElement.setAttribute('src', url);
                                        theAudio.appendChild(audioElement);
+                                       audioElement.load();
+                                       audioElement.play();
                                } else {
                                        // In IE, use the default player for audio/x-wav, probably Windows Media Player
                                        var objectElement = document.createElement('object');
                                                objectElement.setAttribute('filename', url);
                                        } else {
                                                objectElement.setAttribute('data', url);
+                                               if (document.all && !document.addEventListener) {
+                                                       // IE8 only
+                                                       objectElement.setAttribute('type', 'audio/x-wav');
+                                               }
                                        }
                                        theAudio.appendChild(objectElement);
                                        objectElement.style.height = 0;
                                                        paramElement = objectElement.appendChild(paramElement);
                                                }
                                        }
+                                       $altHtml = '<a style="display:inline-block; margin-left: 5px; width: 200px;" href="' + url + '">' + (noPlayMessage ? noPlayMessage : 'Sorry, we cannot play the word of the image.') + '</a>';
                                        if (document.addEventListener) {
                                                // In IE9 and Opera
-                                               objectElement.innerHTML = '<a style="display:inline-block; margin-left: 5px; width: 200px;" href="' + url + '">' + (noPlayMessage ? noPlayMessage : 'Sorry, we cannot play the word of the image.') + '</a>';
+                                               objectElement.innerHTML = $altHtml;
                                        } else {
-                                               objectElement.altHtml = '<a href="' + url + '">' + (noPlayMessage ? noPlayMessage : 'Sorry, we cannot play the word of the image.') + '</a>';
+                                               objectElement.altHtml = $altHtml;
                                        }
                                }
                        } else {