SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Autoplaying a Youtube video via JS without reloading page?

    I can normally fudge my way around JS, but this one has me stumped. Any help would be much appreciated. Thanks.

    I am embedding several youtube videos on a page, by default, youtube videos do not autoplay.

    To get them to autoplay, one simply appends &autoplay=1 to the youtube url.

    E.g. http://www.youtube.com/v/6YR0LGK_HHA&autoplay=1
    (will autoplay)

    As opposed to:
    http://www.youtube.com/v/6YR0LGK_HHA
    (will not autoplay)


    Does anyone know of a cool trick for being able to do this when the client clicks on a JS link labelled Play Video (without refreshing the page)?


    Example embed code below:

    <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"
    id="myFlashMovie" width=481 height=86>
    <param name=movie value="http://www.youtube.com/v/6YR0LGK_HHA">
    <param name=quality value=high>
    <param name=play value=false>
    <param name=bgcolor value=#FFFFFF>
    <embed play=false swliveconnect="true" name="myFlashMovie" src="http://www.youtube.com/v/6YR0LGK_HHA" quality=high bgcolor=#000000 width=481 height=86 type="application/x-shockwave-flash"
    pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
    </embed >

    Many Thanks

  2. #2
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't played with embed elements before, but if you give it an ID can you access it like any other element? Actually thinking about it now you would need to remove the tag and add it back to the DOM to get it to autoplay I believe.

    Regards,
    Jordan

  3. #3
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Issue is that IE doesn't use the Embed, only firefox does, IE uses the other reference.

  4. #4
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you place that entire piece of code in a container div? This way you could use container.innerHTML to replace the content completely. I just don't know if you will be able to start the video without refreshing the page though unfortunately.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •