Help with HTML5 Audio tag?
#1
I'm trying to do a MyCode version of HTML5's audio tag, and I've got it working just fine like this:

\[audio\](.*?)\[/audio\]

replacing
<audio controls="controls" src="$1">Your browser does not support this, blah blah blah.</audio>

and I was trying to get something like this working:

\[audio\ ogg=(.*?) mp3=(.*?) wav=(.*?)](.*?)\[/audio\]

replacing
<audio controls="controls">
<source src="$1" type="audio/ogg" />
<source src="$2" type="audio/mpeg" />
<source src="$3" type="audio/wav" />
$4</audio>

I got that working as long as I typed:
[audio ogg="link to ogg" mp3="" wav=""]blah[/audio]

Which brings me to my question, how can I do it to where I type something like this:

[audio ogg="link to ogg"]blah[/audio]
or
[audio mp3="link to mp3"]blah[/audio]

and have it still work?

In short, how do I have optional tags in a MyCode tag?
Reply
#2
Make two different ones, one for OGG or WMV, otherwise you will need to make it a plugin Mycode
I'm not here often, shoot a PM or whatever if you want my discord.
Reply
#3
Well, I've already done that. There's no need for multiple tags, if there's only one file type, the <audio> tag handles them all, but I want to be able to specify more than one, because not all browsers support all file types. As it is, if I want multiple file types, I have to specify them all in MyCode, even if the url is blank.

I want to be able to specify one or two, without having to have the other urls blank, like:
[audio ogg="url" mp3="url"]blah.[/audio]

and not:
[audio ogg="url" mp3="url" wav=""]blah.[/audio]


But I guess you already answered my question, in that simple Custom MyCode does not support optional parts of a tag. And I don't know any PHP, so I guess I'll deal with it lol.

Thanks for your response.
Reply
#4
Using (.*?) might not always be the best solution since that allows users enter practically everything in there
All my plugins are available for free at MyBB Extend and on my GitHub. MyBB-Plugins.com has been closed and none of my plugins are officially maintained or supported.
Reply
#5
ohai Nervo. :p

but what else can I use? I know literally nothing about PHP, and I've found no documentation on Custom MyCode.

edit: eh, whatever, I'm just going to attempt to make a plugin for it. :p Can't be that hard for something so simple, and I know some programming basics.
Reply
#6
Oh but that's regex not PHP Toungue
All my plugins are available for free at MyBB Extend and on my GitHub. MyBB-Plugins.com has been closed and none of my plugins are officially maintained or supported.
Reply
#7
See, that shows how much I know, haha.

Anyway, I got a plugin nice and made for the Audio tag, now I'm adding the Video tag. ;D
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)