XF 1.4 IE11 will not play attached MP3's

Crossbow

New member
Hello folks,

I seem to have a major problem with IE11 not playing our attached mp3's in post.

I have tried at least 10 players now and none will play. The player shows but you can click the play button till your finger falls off and nothing happens...lol

Chrome and FF has no problems its just IE11. Now here is the kicker if the mp3 is hosted outside of xenforo then it will play just fine in IE11.

I have tested many players on my music site that is not xenforo and they all work fine from that web but not here if its hosted as an attachment inside xenforo.

Hope someone can help me before I pull more hair out and become bald...LOL Thanks in advance.
 
Which player? Are your forum attachments viewable for guests?

It might be related to the Content-type header which can be seen in this file:

library/XenForo/ViewPublic/Attachment/View.php

XenForo sends a specific Content-type for images. Otherwise it uses 'application/octet-stream'. You can try coding in a 'audio/mpeg' Content-type for mp3s to see if that makes a difference.
 
Hey Jake, Thanks for the reply.

The player is Mediaelement, Guest are not allowed to see anything unless they join our board.

The player showing with no problem and plays in IE 8, Chrome and Firefox but will not play in IE 11.

It shows in IE11 but will not play.

I added in your code in the "View.php" but made no difference.
 
Last edited by a moderator:
I should add that when using IE11 the play button does work as it will switch from play to pause when clicking the play button so that works.

Just will not play the attached file for some reason. Blows my mind that IE8 works but not IE11...
 
Testing things locally, but it does look like the <audio> tag won't play with a content type of application/octet-stream; if it's using the Flash fallback, I'm not sure what constraints that would have (perhaps that and the content-disposition). The audio tag switches to "invalid source" with the application/octet-stream content type.

The code would need to be modified to give mp3 an entry in the "imageTypes" variable with a content type.
 
library/XenForo/ViewPublic/Attachment/View.php

Rich (BB code):
		$imageTypes = array(
			'gif' => 'image/gif',
			'jpg' => 'image/jpeg',
			'jpeg' => 'image/jpeg',
			'jpe' => 'image/jpeg',
			'png' => 'image/png',
			'mp3' => 'audio/mpeg'
		);
 
Hey Jake,

Added that in and made no difference. Still not working :(

Code:
$imageTypes = array(

            'gif' => 'image/gif',

            'jpg' => 'image/jpeg',

            'jpeg' => 'image/jpeg',

            'jpe' => 'image/jpeg',

            'png' => 'image/png'
           
            'mp3' => 'audio/mpeg'

        );
 
After adding that in I am getting server errors:
Fatal Error: syntax error, unexpected T_CLASS 2 minutes ago - library/XenForo/ViewPublic/Attachment/View.php:1
 
That would seem to imply that the code wasn't edited properly. Probably best to revert and try again.

I should just note that any sort of code editing isn't something we'd recommend (or officially support).
 
Well its fried now... I took the added code out and none of our attachments work now. I used FTP to download the file to edit as I do not know how to do it from the admin side..
 
Which application did you use to edit the file?
I usually recommend Notepad ++ and saving as UTF-8 without BOM.

You can upload the copy from your .zip to restore the original file.
 
Hey Jake,

Added that in and made no difference. Still not working :(

Code:
$imageTypes = array(

            'gif' => 'image/gif',

            'jpg' => 'image/jpeg',

            'jpeg' => 'image/jpeg',

            'jpe' => 'image/jpeg',

            'png' => 'image/png'
          
            'mp3' => 'audio/mpeg'

        );
Code:
            'png' => 'image/png'
should be

Code:
            'png' => 'image/png',
 
Thats what I done was uploaded the new one from the zip folder to fix the problem. Now chrome and IE11 sends the server error when trying to play the attached song. IE 8 works fine... I am at work and my backup file is at home so I can not get to it for now.. I am sure its a small coding thing to make chrome to work again.
 
ErrorException: Fatal Error: syntax error, unexpected T_CLASS -

Where is it wrong now ?

Code:
<?php



/**

* View to handle displaying an attachment.

*

* @package XenForo_Attachment

*/

class XenForo_ViewPublic_Attachment_View extends XenForo_ViewPublic_Base

{

    public function renderRaw()

    {

        $attachment = $this->_params['attachment'];
       
        $content-type = audio/mpeg(
        'mp3' => 'audio/mpeg',
        'mp3' => 'audio/mp3'
        );



        $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);

        $imageTypes = array(

            'gif' => 'image/gif',

            'jpg' => 'image/jpeg',

            'jpeg' => 'image/jpeg',

            'jpe' => 'image/jpeg',

            'png' => 'image/png',
           
            'mp3' => 'audio/mpeg'
           
            );



        if (in_array($extension, array_keys($imageTypes)))

        {

            $this->_response->setHeader('Content-type', $imageTypes[$extension], true);

            $this->setDownloadFileName($attachment['filename'], true);

        }

        else

        {

            $this->_response->setHeader('Content-type', 'application/octet-stream', true);

            $this->setDownloadFileName($attachment['filename']);

        }



        $this->_response->setHeader('ETag', '"' . $attachment['attach_date'] . '"', true);

        $this->_response->setHeader('Content-Length', $attachment['file_size'], true);

        $this->_response->setHeader('X-Content-Type-Options', 'nosniff');



        return new XenForo_FileOutput($this->_params['attachmentFile']);

    }

}
 
Back
Top Bottom