This topic contains 11 replies, has 0 voices, and was last updated by  Laptops Daddy 6 years, 7 months ago.

  • Author
    Posts
  • #6643

    Deathstryker
    Participant

    It’d be handy if you could implement support for embedded Youtube vids on the forums.

    Handy tutorial on how to do this with phpbb (ironically a youtube vid):

    #53635

    Laptops Daddy
    Participant

    nice tutorial. you musnt go adding object and embed tags as bb code, though. youd supplant the flash plugin detection ive already coded.

    we’re very cross-platform. if we’re going to embed flash, we need to use an ‘swfobject (http://en.wikipedia.org/wiki/SWFObject) style’ javascript technique*. (add a placeholder, check for the plugin and append the object to the placeholder if the browser has a flash plugin)

    for 2 cents:
    i personally dont like youtubes in forums.

    feature requests – something id like to see is a strikethrough button for text.

    *SWFObject style : / the code i wrote/still use to do the same thing (better, i think) predates SWFObject’s first release by about 6 months. bstds : ) here’s to recognition.

    #53634

    Deathstryker
    Participant

    Booooo. Stick in the mud.

    #53633

    Laptops Daddy
    Participant

    @deathstryker wrote:

    Booooo. Stick in the mud.

    it’d be your say more than mine, far as im concerned. i didnt mean to sound like i was ruling it out! it could be done, just slightly differently, but it’s not for me to decide.

    #53636

    Deathstryker
    Participant

    How long will it be before the forum design is changed and therefore will utilize your code for embedding videos?

    #53637

    Laptops Daddy
    Participant

    i’d planned to finish most of the work on the new site this week. as to when it’s implemented, that’ll depend on gavin. if we want a smooth swap, we must test everything thoroughly and the time scale on that will probably depend on how many volunteers i can corner.

    i dont know if i was clear about my objection to using object/embed for youtubes in forums. the point was less that it would conflict with anything special ive done and more that it’s a bad idea for cross platform sites (which is why most people including adobe and youtube themselves where theyre looking for something a bit more robust, do it differently).

    i expect the tutorial in the youtube you linked to was only meant to be an example of one way you could do it. i’d be surprised if the phpbb devs saw things differently. so, i wasnt ruling out a [youtube] bb tag . we’d just need to take a little care to do it right. (same would apply on the existing site).

    anyway, do you really think it’s a good idea? you might end up with a ton of extra nonsense on the forums.

    #53638

    Viking62
    Participant

    Instead of embedding….um…. could you perma-link to just a YouTube/Scorched3d search? (That way all the videos*(current & future)* from various authors show up when going to the link)?

    ie/Re: http://www.youtube.com/results?search_query=scorched3d&search_type=&aq=f

    Like, a button with the link embedded.

    This is kinda cool:(can choose preference)
    http://www.buttonshut.com/Youtube-Buttons/

    #53639

    Deathstryker
    Participant

    @laptops Daddy wrote:

    …you might end up with a ton of extra nonsense on the forums.

    I’m used to it. Besides, us moderators gotta have SOMETHING to do.

    #53640

    Laptops Daddy
    Participant

    k. just for fun then/as a hypothetical, what dyou thinks the nicest way to go about it?

    we probably dont need to modify any of the phpbb php and template stuff directly. what if we lost those tags and wrote out a container div to append to with some javascript document.write?

    i guess the problem would be setting up a unique id for that container div so we can get hold of it later and it doesnt break the markup. (html element id’s have to be unique). i spose a plan could be to take the post id from the current page uri and use that as part of the element id? i dont know if youd want to allow for two or more [youtube]s per forum post, so, i guess you could add a random number to each. would that be cool, or is that too hacky?

    it wouldnt work for post previews, but the uri for a posted post (eg

    http://www.scorched3d.co.uk/phpBB3/viewtopic.php?f=11&p=59212#p59212

    has a nice unique number at the end. shouldnt be a prob to get hold of that in javascript with document.location.href and a regexp or something.

    ps:
    @deathstryker wrote:

    I’m used to it.

    touché i guess : )

    #53641

    Deathstryker
    Participant

    You seem to know miles more about website code than I do so I’ll let you be the judge. While I did understand how the tutorial works on the youtube link I posted, it’s apparent that you have in mind something much more advanced and farther reaching than my mind can accomplish.

    #53642

    Laptops Daddy
    Participant

    *scans for sarcasm*

    yeah, youd be amazed how often i hear that. i probably just wasnt explaining it well.

    anyway, this code seems to work quite nicely:


    // <![CDATA[

    var embedobj = document.createElement("embed");
    var attNames = new Array("type","src","width","height","bgcolor");
    var attVals = new Array("application/x-shockwave-flash","{TEXT}","400","300","#000000");
    var i = 0;
    do {
    embedobj.setAttribute(attNames,attVals);
    i++;
    }
    while (i < attVals.length);

    var txt = document.location.href;
    var re = '.*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?(?:[a-z][a-z0-9_]*).*?((?:[a-z][a-z0-9_]*))';
    var p = new RegExp(re,["i"]);

    var m = p.exec(txt);
    if (m != null)
    {
    var var1=m[1];
    var postId = var1.replace(/</,"<");
    var randNo = Math.floor(Math.random()*1001);
    var elementId = postId + randNo;

    document.write("
    ");
    document.getElementById(elementId).appendChild(embedobj);
    }

    // ]]>

    if we do it like that, y’see, we can wrap the whole thing in an “if there’s a flash plugin” test and we won’t have any of this nonsense when people dont have one installed:
    [attachment=0:ukoae0dy]nothanks.png[/attachment:ukoae0dy]
    (which really isnt fitting on a cross-platform site that means business)

    i do feel a bit like we’re building a garden in a window box with that, but to me it seems a lot less invasive than modding phpbb’s inner workings.

    #53643

    Laptops Daddy
    Participant

    @deathstryker wrote:

    @laptops Daddy wrote:

    …you might end up with a ton of extra nonsense on the forums.

    I’m used to it.

    speaking of nonsense…

    i was pondering this a bit more, just for fun. extracting the post id from the uri won’t help. i was neglecting that each forum post might have a few others above and below it. that regex stuff is pointless.
    (im kind of thinking/typing out loud here)

    maybe i have a cleaner way to do this anyway. i didnt really like relying on a random number without a check to be sure there were no repeats.

    this might work:


    // <![CDATA[
    var embedobj = document.createElement("embed");
    var attNames = new Array("type","src","width","height","bgcolor");
    var attVals = new Array("application/x-shockwave-flash","{TEXT1}youtube.com/v/{TEXT2}","400","300","#000000");
    var i = 0;
    do {
    embedobj.setAttribute(attNames,attVals);
    i++;
    }
    while (i < attVals.length);
    var elementId = 'youtube' + Math.floor(Math.random()*1001);
    if (document.getElementById(elementId) == null) {
    document.write("
    ");
    } else {
    do
    {
    elementId = 'youtube' + Math.floor(Math.random()*1001);
    document.write("null");
    }
    while(!(document.getElementById(elementId) == null));
    document.write("
    ");
    }
    document.getElementById(elementId).appendChild(embedobj);
    // ]]>

    it’s a little dirty with a loop like that, but there’s no way it would hurt unless we had a thousand youtubes on each page. i think id be happy with that code, personally.

    wouldnt hurt to have it tested a bit.

    *edit. gavin, dont let me loose with that stuff.

    #53644

    Laptops Daddy
    Participant

    thanks spammer. we must finish all that! we have a lovely website. must must get it tied up.

    ps:
    autotune. it’ll make any madonna sound like a tortured cat and vice versa
    http://en.wikipedia.org/wiki/Auto-Tune

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.