How to convert url to embed code from youtube and vimeo url dynamically

  1. How to convert url to embed code from youtube url

    1. Get the video id

       
    2. Create embed url from vedio id
      The iframe src of youtube is http://www.youtube.com/embed/$vedio_id so the embed code would be

      For autoplay you use autoplay=1 parameter.
    3. get youtube vedio thumbnail
      you can get thumbnail of any youtube vedio with the url
      Large thumbnail : http://img.youtube.com/vi/$vedio_id/0.jpgSmall thumbnail : http://img.youtube.com/vi/$vedio_id/1.jpg
      and so on…

    How to convert url to embed code from vimeo url

    1. Get the video id.

       
    2. Create embed url from vedio id.
      The embed url for vimeo is
      $embedurl = “http://player.vimeo.com/video/”.$vedio_id;
      and iframe code for vimeo would be
    3. Get vedio thumbnail of vimeo.
      this step is slightly diffrent then youtube in this case we will  read video files in the vimeo server and locate its thumbnail image.
    I needed this code when i was creating a wordpress theme for a client
    it was a video blog and client need this functionality to its wp admin panel with autoplay control.
    you have to add just youtube url and it will automatically generate an embeded video on the front page.there is an option for embed code . you can see demo and download the source code below for free.Hope this thing helps you.Happy coding.


    Read more: http://buffernow.com/youtube-url-to-embed-code-generator-php-script/#ixzz3W5TSVZpQ

No comments:

Post a Comment