News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Play Media Attachments

Started by dougiefresh, December 30, 2016, 11:43:52 PM

Previous topic - Next topic

dougiefresh

Link to Mod



PLAY MEDIA ATTACHMENTS v2.6
By Dougiefresh -> Link to Mod



Introduction
This mod allows MP3, WAV, WMA, AAC, and audio OGG files that has been attached to a post to be played without manually downloading the attachment using the HTML5 audio tag.

This mod also allows a MP4, M4A, M4V, WebM, WMV, MOV, and video OGG files that has been attached to a post to be played without manually downloading the attachment using the HTML5 video tag.

Note: OGG format files are assumed to be video if the extension is OGV.  Detection has yet to be improved upon for determining the difference between audio and video OGG-formatted files.

Admin Settings
In Admin -> Forum -> Attachments and Avatars -> Attachment Settings, there are two new options:
o Width of Audio Player element
o Width of Video Player element

Inspiration & Credit
The Javascript code used was copied and adapted from this webpage: JavaScript spoiler with a twist (collapsing up or down)

Compatibility Notes
This mod was tested on SMF 2.0.14, but should work on SMF 2.0 and up, as well as SMF 2.1 RC2.  SMF 2.1 RC1 and before, as well as SMF 1.x will not be supported.

PM Attachments should be installed before this mod (not required).  Only PM Attachments mod version 2.1 and above are supported!

Changelog
The changelog can be viewed at XPtsp.com.

License
Copyright (c) 2016 - 2019, Douglas Orend
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

dougiefresh

Uploaded v1.1 - December 31st, 2016
o Changed text string in the <audio> tag to localizable string.
o Added support for SMF 2.1 Beta 2.

Steve

DO NOT pm me for support!

dougiefresh

Quote from: Ghislain.Dejoie on January 04, 2017, 05:46:38 AM
Hello,
It's still "the hindrance to turn in circles!"
I note a concern:
I am connected, I attach an MP3 file to a subject and I click on "Submit"
The subject is published, the file is attached BUT the reading bar does not appear!
I leave the subject published.
I uninstall the Mod (without erasing it)
I reinstall the Mod AND the playbar appears!
Bizarre
Obviously, the mime type didn't get put into the database properly.  I'll look into this bug report!

dougiefresh

Uploaded v1.2 - January 4th, 2016
o Changed code so that audio/video MIME detection takes place if no MIME type detected.

Steve

Hmm ... can't seem to get this to work for some reason now ... attaching an mp3 just shows it as an attachment with no player.
DO NOT pm me for support!

Ghislain.Dejoie

#6
Hello,
Result of the implementation of version 1.2:
I did my tests on 5 browsers and it works!
I have allowed single visitors to view attachments, and it also works
THANK YOU

dougiefresh

@Steve: Can't reproduce your bug report about the MP3 file.  Can you upload the file somewhere (not here) and PM me with the link to it?  Thanks!

@Ghislain.Dejoie:  Thank you for your feedback!

Steve

After your request I checked and other mp3's work fine so it's something about the particular one I'm trying to use. Where's a good place to upload it?
DO NOT pm me for support!

dougiefresh

Dropbox, 4shared, or similar services would work.  Just Google file sharing services and pick one....

Steve

DO NOT pm me for support!

dougiefresh

Uploaded v1.3 - January 7th, 2017
o Fixed MIME detection for MP3 files.




@Steve:  This update should address the issue, as the magic byte detection was incorrect for MP3 files.  Thank you for the bug report!

Steve

Quote from: dougiefresh on January 07, 2017, 08:54:32 PM@Steve:  This update should address the issue ... Thank you for the bug report!

Works great now! Thanks Dougie!
DO NOT pm me for support!

Dave J

Hi Dougie,

Unfortunately after I install this mod I get the errors below.

I'm using SMF 2.0.13. I am using a custom theme but I don't think that would that cause the Display errors.

There are no errors prior to the mod install and none once it's been removed.

Any ideas?
If you want quizzes to add to the new SMF2.1 quiz mod go here . There are also walkthroughs in the forum to explain how to install them and other tips.

dougiefresh

Uploaded v1.4 - February 21st, 2017
o Fixed invalid array index error in Sources/Display.php.




@davejo:  This update should take care of the undefined array index errors you saw.  Thank you for the bug report!

Dave J

Thanks Dougie, I will let you know how I get on tomorrow (Wednesday)
If you want quizzes to add to the new SMF2.1 quiz mod go here . There are also walkthroughs in the forum to explain how to install them and other tips.

Dave J

Quote from: dougiefresh on February 21, 2017, 09:45:08 AM
Uploaded v1.4 - February 21st, 2017
o Fixed invalid array index error in Sources/Display.php.




@davejo:  This update should take care of the undefined array index errors you saw.  Thank you for the bug report!

Yep it works a treat Dougie, thanks very much for the quick reply and fix it's much appreciated.
If you want quizzes to add to the new SMF2.1 quiz mod go here . There are also walkthroughs in the forum to explain how to install them and other tips.

ircsiinci

Dougiefresh Hi!

Unfortunately for me it does not work.
I'm using SMF 2.0.13

To ask for help.

Thanks in advance.

Otherwise, great job, thank you., :)

Have a nice day!
........ Because she said it is better to give than to receive.

Steve

What does not work? What is it not doing?
DO NOT pm me for support!

dougiefresh

#19
Quote from: ircsiinci on February 22, 2017, 05:23:16 AM
Dougiefresh Hi!

Unfortunately for me it does not work.
I'm using SMF 2.0.13

To ask for help.

Thanks in advance.

Otherwise, great job, thank you., :)

Have a nice day!
If you are thinking that the mod is supposed to automatically play the attachment, then you are mistaken.  Is that the issue?

EDIT:  Or does the audio player not play the audio file you attached?  If this is the case, you should upload the file somewhere (not here, potential copyright issues) and PM me the link to the file, so that I can see what the issue is with the file.....

Without more information, attempting to reproduce this bug report is damn near impossible.....

Advertisement: