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

Trouble with video file attachments

Discussion in 'XenForo Development Discussions' started by Freelancer, Jan 16, 2016.

  1. Freelancer

    Freelancer Well-Known Member

    I extended the file attachment template to recognize if audio or video files are shown. It adds an html5 player and works great with MP3 audio attachments. Files can be played as an attachment.

    However I am not able to get .mp4 or any other video files to be shown. The player is displayed but the video is not shown. It seems that the video is not streamed or loaded... Is it a problem with XF link system for attachments?

    I have made an extra template that is called within the attached_files template with the following code:

    Code:
    <xen:if is="{$attachment.extension} == 'mp3'">
                            <xen:include template="attached_files_av_player" />
                        </xen:if>
                       
                        <xen:if is="{$attachment.extension} == 'mp4'">
                            <xen:include template="attached_files_av_player" />
                        </xen:if>
    The template attached_files_av_player looks as follows:

    Code:
    <div class="attachmentsAV">
        <xen:if is="{$attachment.extension} == 'mp3' ">
            <audio  width="auto" height="24" src="{xen:link attachments, $attachment}" type="audio/mpeg" controls="controls" preload="none"></audio>
        </xen:if>
                   
        <xen:if is="{$attachment.extension} == 'm4v' ">
            <video width="auto" controls="controls">
                <source src="{xen:link attachments, $attachment}" type="video/m4v">
                Your browser does not support HTML5 video.
            </video>
        </xen:if>
       
        <xen:if is="{$attachment.extension} == 'mp4' ">
            <video width="auto" controls="controls">
                <source src="{xen:link attachments, $attachment}" type="video/mp4">
                Your browser does not support HTML5 video.
            </video>
        </xen:if>
       
        <xen:if is="{$attachment.extension} == 'mov' ">
            <video width="auto" controls="controls">
                <source src="{xen:link attachments, $attachment}" type="video/mov">
                Your browser does not support HTML5 video.
            </video>
        </xen:if>
    </div>
    I am pretty sure this can be handled in a better way and this is just very crude...

    Also, in debug mode I get an "illegal string offset" warning for the if conditional "extension". I wonder if this can be ignored or if it is part of the problem...

    Any help appreciated.
    Cheers
     

Share This Page