1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 IE11 will not play attached MP3's

Discussion in 'Troubleshooting and Problems' started by Crossbow, Feb 3, 2015.

  1. Crossbow

    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.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.
     
    Crossbow likes this.
  3. Crossbow

    Crossbow New Member

    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: Feb 6, 2015
  4. Crossbow

    Crossbow New Member

    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...
     
  5. Mike

    Mike XenForo Developer Staff Member

    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.
     
    Crossbow likes this.
  6. Crossbow

    Crossbow New Member

    Hey Mike, Thanks for the reply...

    Bit confused on give mp3 an entry.. Can you give me an example ?
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    library/XenForo/ViewPublic/Attachment/View.php

    Code:
    		$imageTypes = array(
    			'gif' => 'image/gif',
    			'jpg' => 'image/jpeg',
    			'jpeg' => 'image/jpeg',
    			'jpe' => 'image/jpeg',
    			'png' => 'image/png',
    			'mp3' => 'audio/mpeg'
    		);
    
     
    rveram and Crossbow like this.
  8. Crossbow

    Crossbow New Member

    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'
    
            );
     
  9. Mike

    Mike XenForo Developer Staff Member

    Can you show us a demonstration? (We'll need to be able to see the attachment in question so guests would need access.)
     
    Crossbow likes this.
  10. Crossbow

    Crossbow New Member

    Hey Mike,

    Check your PM...
     
  11. Crossbow

    Crossbow New Member

    Keep in mind its only if your using IE11...
     
  12. Crossbow

    Crossbow New Member

    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
     
  13. Mike

    Mike XenForo Developer Staff Member

    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).
     
    Crossbow likes this.
  14. Crossbow

    Crossbow New Member

    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..
     
  15. Brogan

    Brogan XenForo Moderator Staff Member

    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.
     
    Crossbow likes this.
  16. EQnoble

    EQnoble Well-Known Member

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

    Code:
                'png' => 'image/png',
     
    Crossbow likes this.
  17. Crossbow

    Crossbow New Member

    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.
     
  18. Crossbow

    Crossbow New Member

    Yep notepad ++ is what I use as well.
     
  19. Crossbow

    Crossbow New Member

    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']);
    
        }
    
    }
     
  20. Crossbow

    Crossbow New Member

    Giving that error when using Chrome and IE11.. Says file not found... IE8 works fine.. This is getting so weird...
     

Share This Page