Fixed bug #47810: Audio Captcha not working under IE 8
authorstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Thu, 4 Jul 2013 16:50:03 +0000 (16:50 +0000)
committerstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Thu, 4 Jul 2013 16:50:03 +0000 (16:50 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/sr_freecap/trunk@77216 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
Resources/Public/JavaScript/freeCap.js

index 5fa8424..db02405 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-07-04  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #47810: Audio Captcha not working under IE 8
+
 2013-06-19  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Added feature #49272: Add support for mp3 audio captcha rendering
index 51328ed..ca44155 100644 (file)
@@ -70,7 +70,7 @@
                                if (audioElement.canPlayType) {
                                        // HTML 5 audio
                                        if (audioElement.canPlayType('audio/mpeg') === 'maybe' || audioElement.canPlayType('audio/mpeg') === 'probably') {
-                                               url = url.replace('wav', 'mp3');
+                                               url = url.replace('formatName=wav', 'formatName=mp3');
                                        }
                                        audioElement.setAttribute('src', url);
                                        audioElement.setAttribute('id', 'tx_srfreecap_captcha_playAudio_audio' + id);
                                        audioElement.load();
                                        audioElement.play();
                                } else {
-                                       url = url.replace('wav', 'mp3');
+                                       url = url.replace('formatName=wav', 'formatName=mp3');
                                        // In IE, use the default player for audio/mpeg, probably Windows Media Player
                                        var objectElement = document.createElement('object');
                                        objectElement.setAttribute('id', 'tx_srfreecap_captcha_playAudio_object' + id);
-                                       objectElement.setAttribute('data', url);
-                                       // IE 7
-                                       objectElement.setAttribute('filename', url);
+                                       objectElement.setAttribute('type', 'audio/x-mpeg');
+                                        if (document.all && !document.addEventListener) {
+                                               if (!document.querySelector) {
+                                                       // IE7 only
+                                                       objectElement.setAttribute('filename', url);
+                                                } else {
+                                                       // IE8 only
+                                                       objectElement.setAttribute('data', url);
+                                                }
+                                        }
                                        theAudio.appendChild(objectElement);
                                        objectElement.style.height = 0;
                                        objectElement.style.width = 0;