Playing YouTube video with the twitter bootstrap framework

In this tutorial, I'm going to show you how to embed YouTube video in a web page using the twitter bootstrap framework. Since we will be using bootstrap for convenient and nice looking web application. First you need to download the twitter bootstrap framework. Then after you download the twitter bootstrap, extract and copy the files such as: css, fonts and js folder. After this step, create a new folder and name it as “myvids” then paste the three files inside “myvids” folder, and put this folder in the local server. Here’s the folder structure: myvids/ ├── css/ │ ├── bootstrap.css │ ├── bootstrap.min.css │ ├── bootstrap-theme.css │ ├── bootstrap-theme.min.css ├── js/ │ ├── bootstrap.js │ ├── bootstrap.min.js └── fonts/ ├── glyphicons-halflings-regular.eot ├── glyphicons-halflings-regular.svg ├── glyphicons-halflings-regular.ttf └── glyphicons-halflings-regular.woff Then, let's create a new PHP file and save it as “video.php”. And add the following code:
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="utf-8">
  5.   <meta content="width=device-width, initial-scale=1.0" name="viewport">
  6.   <meta content="" name="description">
  7.   <meta content="" name="author">
  8.   <link href="" rel="shortcut icon">
  9.  
  10.   <title>Playing Youtube Video using Twitter Bootstrap</title>
  11.   <!-- Bootstrap core CSS -->
  12.   <link href="css/bootstrap.min.css" rel="stylesheet">
  13. </head>
  14.  
  15. <body>
  16.   <div class="container">
  17.     <div class="well">
  18.       <h3>Playing Youtube Video</h3>
  19.     </div>
  20.  
  21.     <div class="well">
  22.         <!---This section for panel component-->
  23.    
  24.     </div>
  25.   </div><!-- /container -->
  26. </body>
  27. </html>
Next,inside the second class well. Add the following code: In this code, we will put DOM in a box that will hold our YouTube video and video description, and in our situation we use the panel component.
  1. <div class="panel panel-primary">
  2.         <div class="panel-heading">
  3.           <h3 class="panel-title">The X Life - Episode 1 | "She Knew What She
  4.          Married"</h3>
  5.         </div>
  6. <div class="panel-body">
  7.         <!---This section for media object->
  8.  </div>
  9.       </div>
Then, inside the class panel-body. Add the following code:
  1. <div class="media">
  2.     <a class="pull-left" href="#"><iframe frameborder="0" height="315" src=
  3.     "//www.youtube.com/embed/b27uk5edY5M" width="420"></iframe></a>
  4.  
  5.     <div class="main-body">
  6.       <!-- this section we will add information about the video-->
  7.  
  8.       <p><strong>Season 1 - Episode 1</strong> The X-Life is an American
  9.       reality television series on VH1 that follows three extreme athletes and
  10.       their wives as they navigate their lives with their famous careers.</p>
  11.     </div>
  12.   </div>
After this the video.php file should look like as shown below.
  1. <!DOCTYPE html>
  2.  
  3. <html lang="en">
  4. <head>
  5.   <meta charset="utf-8">
  6.   <meta content="width=device-width, initial-scale=1.0" name="viewport">
  7.   <meta content="" name="description">
  8.   <meta content="" name="author">
  9.   <link href="" rel="shortcut icon">
  10.  
  11.   <title>Playing Youtube Video using Twitter Bootstrap</title>
  12.   <!-- Bootstrap core CSS -->
  13.   <link href="css/bootstrap.min.css" rel="stylesheet">
  14. </head>
  15.  
  16. <body>
  17.   <div class="container">
  18.     <div class="well">
  19.       <h3>Playing Youtube Video</h3>
  20.     </div>
  21.  
  22.     <div class="well">
  23.       <!---This section for panel component-->
  24.  
  25.       <div class="panel panel-primary">
  26.         <div class="panel-heading">
  27.           <h3 class="panel-title">The X Life - Episode 1 | "She Knew What She
  28.          Married"</h3>
  29.         </div>
  30.  
  31.         <div class="panel-body">
  32.           <!--This section for media-->
  33.  
  34.           <div class="media">
  35.             <a class="pull-left" href="#"><iframe frameborder="0" height="315"
  36.             src="//www.youtube.com/embed/b27uk5edY5M" width="420"></iframe></a>
  37.  
  38.             <div class="main-body">
  39.               <!-- this section we will add information about the video-->
  40.  
  41.               <p><strong>Season 1 - Episode 1</strong> The X-Life is an
  42.               American reality television series on VH1 that follows three
  43.               extreme athletes and their wives as they navigate their lives
  44.               with their famous careers.</p>
  45.             </div>
  46.           </div>
  47.         </div>
  48.       </div>
  49.     </div>
  50.   </div><!-- /container -->
  51. </body>
  52. </html>
And the output should look like as shown below. component_panel As you can observe we have used different class in our code above. These are:
  1. class="container"
  2. class="well"
  3. class="panel panel-primary"
  4. class="panel-heading"
  5. class="panel-title"
  6. class="panel-body"
  7. class="media"
  8. class="pull-left"
  9. class="main-body"

Add new comment