MyBB Community Forums
mycod for html5 mp3/mp4 player - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Resources (https://community.mybb.com/forum-8.html)
+--- Forum: MyCodes (https://community.mybb.com/forum-117.html)
+--- Thread: mycod for html5 mp3/mp4 player (/thread-233708.html)

Pages: 1 2


mycod for html5 mp3/mp4 player - ehssan_it - 2021-09-26

hi
I'm a code for translating video links and mp4 and mp3 to html5 players,

Links may be as follows:

https://example/sound.mp3
or
https://example/sound.mp4

or text that links to an audio file or video

If other than mp3 can convert other audio formats into a player, it is very good.


RE: mycod for html5 mp3/mp4 player - Crazycat - 2021-09-26

mp3 are audio, mp4 are videos, so you can't use the same MyCode as the resulting html won't be the same.

Audio
Regular expression: (https?:\/\/.+\.(mp3|wav|ogg))\s
Replacement
<audio controls><source src="$1">Audio: $1</audio>

Video
Regular expression: (https?:\/\/.+\.(mp4|avi|webm))\s
Replacement
<video controls><source src="$1">Video: $1</video>

Note that you'll lack some important informations as the type (mimetype) of the source and, in videos, the size.


RE: mycod for html5 mp3/mp4 player - ehssan_it - 2021-09-26

when I build that mycode,
Nothing happens


RE: mycod for html5 mp3/mp4 player - Crazycat - 2021-09-26

(2021-09-26, 12:53 PM)ehssan_it Wrote: when I build that mycode,
Nothing happens

It works for me but needs a small correction:
Audio
Regular expression: (https?:\/\/[^\s]+\.(mp3|wav|ogg))\s
Replacement
<audio controls><source src="$1">Audio: $1</audio>

Video
Regular expression: (https?:\/\/[^\s]+\.(mp4|avi|webm))\s
Replacement
<video controls><source src="$1">Video: $1</video>

My test post :
I'm a code for translating video links and mp4 and mp3 to html5 players,

Links may be as follows:

https://example/sound.mp3
or
https://example/sound.mp4

or text that links to an audio file or video

If other than mp3 can convert other audio formats into a player, it is very good.

Result:
[Image: tPWxvzU.png]


RE: mycod for html5 mp3/mp4 player - Mostafa.Shiraali - 2021-09-30

delete "\s" from end of regex string.


RE: mycod for html5 mp3/mp4 player - juoum - 2022-02-28

(2021-09-30, 08:05 AM)Mostafa.Shiraali Wrote: delete "\s" from end of regex string.

Hey, sorry to bother.

I've done all the above but I still can't see any videos on my posts.
Whenever I insert a link to my post and try to preview it, it shows nothing. Not event the text I had previously written.

It works just fine on the sandbox.

[Image: ci5spA8.png]

[Image: aQ4mipR.png]

Any idea on how to solve this?
Thanks in advance!


RE: mycod for html5 mp3/mp4 player - Crazycat - 2022-03-01

Did you try to disable all plugins ? Which version of MyBB do you use ?
Can you provide an url and a test account ?


RE: mycod for html5 mp3/mp4 player - juoum - 2022-03-01

(2022-03-01, 07:56 AM)Crazycat Wrote: Did you try to disable all plugins ? Which version of MyBB do you use ?
Can you provide an url and a test account ?

I disabled all plugins but it made no difference. I am running MyBB 1.8.29.

URL: http://ruwl2j74zbswk5lla5j5m4um5sccsb2mu6qadjiatjtx6sci3unz6sqd.onion

Test acc:

username: crazycat
pwd: CrazyFrog1


RE: mycod for html5 mp3/mp4 player - Crazycat - 2022-03-01

lol, onion site...
This is probably the primary reason explaining the media is not loaded. Tor blocks a lot of functionnalities.

And the second: your site is actually offline


RE: mycod for html5 mp3/mp4 player - juoum - 2022-03-04

(2022-03-01, 10:32 PM)Crazycat Wrote: lol, onion site...
This is probably the primary reason explaining the media is not loaded. Tor blocks a lot of functionnalities.

And the second: your site is actually offline

I am pretty aware that TOR blocks lots of things. Although, a simple html5 video player shouldn't be blocked. Even if it blocks video elements (which I highly doubt) that wouldn't explain why it works on the sandbox and not on the post though.

And yeah, I am having some issues with my website hosting provider. ty for the heads-up though!