MyBB Community Forums

Full Version: mycod for html5 mp3/mp4 player
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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.
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.
when I build that mycode,
Nothing happens
(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]
delete "\s" from end of regex string.
(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!
Did you try to disable all plugins ? Which version of MyBB do you use ?
Can you provide an url and a test account ?
(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://ruwl2j74zbswk5lla5j5m4um5sccsb2mu...6sqd.onion

Test acc:

username: crazycat
pwd: CrazyFrog1
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
(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!
Pages: 1 2