1 Sep 2013

Published 01:31 by with 12 comments

PHPMOTION JW Player Integration

phpmotion is a popular video script.by default phpmotion uses flash player to show/play videos at home page as well as video play page.The JW Player is the Internet's most advanced and flexible media player. in this tutorial I am going to show how it is really easy to do phpmotion jw player integration.

phpmotion jw player integration tutorial by renruhak.org





follow below steps for phpmotion jw player integration.

01. open  themes/default/templates/main_1.htm
go to

<script type="text/javascript" src="[var.base_url]/javascripts/jquery-1.2.3.pack.js">


and remove the next commented line and add jQuery.noConflict(); so it will be as below after change


<script type="text/javascript" src="[var.base_url]/javascripts/jquery-1.2.3.pack.js"></script>
  <script>jQuery.noConflict();</script>


02. open index.php

goto

$browse_videos = array();


and above it add the below code. here you may modify the sql statement as per your need.

$sql = "SELECT indexer, video_id, title, title_seo, date_uploaded, user_id, video_length, featured, approved, public_private FROM videos WHERE indexer=4 and approved='yes' AND public_private = 'public' ORDER BY RAND() DESC LIMIT 1";
$query = @mysql_query($sql);
if ($result_videos = @mysql_fetch_array($query)) {
$my_video_id       = mysql_real_escape_string($result_videos['video_id']);
}
$sql = "SELECT indexer, video_id,type, title, title_seo, date_uploaded, user_id, video_length, featured, approved, public_private FROM videos WHERE approved='yes' AND public_private = 'public' ORDER BY indexer DESC";
$query = @mysql_query($sql);
$countvids =1;
$plist ='';
while ($result_videos = @mysql_fetch_array($query)) {
         $my_video_id = mysql_real_escape_string($result_videos['video_id']);
         $type = mysql_real_escape_string($result_videos['type']);
         $title = mysql_real_escape_string($result_videos['title']);
         if($countvids == 1)
         {

                 $plist ='{';
               $plist.='image:"http://localhost/phpmotion_autoembed/uploads/thumbs/'.$my_video_id.'.jpg",';
               $plist.='file:"'.$base_url.'/uploads/'.$my_video_id.'.'.$type.'",';
               $plist .='title:"'.$title.'"';
               $plist .='}';
         }else
         {

               $plist .=',{';
               $plist.='image:"http://localhost/phpmotion_autoembed/uploads/thumbs/'.$my_video_id.'.jpg",';
               $plist.='file:"'.$base_url.'/uploads/'.$my_video_id.'.'.$type.'",';
               $plist .='title:"'.$title.'"';
               $plist .='}';
         }
         $countvids++;
}


03. now open  themes/default/templates/inner_index.htm

here

find the code as below

<!--Video Player Container.  This is where the player embed code goes-->
  <div id="index-player-container">
<div id="myAlternativeContent">
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
</div>
     <script type="text/javascript">
     var flashvars = {};
     var params = {};
     var attributes = {};
     flashvars.player_mode = "playlist";
     flashvars.display_ads = "no";
     flashvars.playlist = "yes";
     flashvars.playlist_xml = "[var.base_url]/playlist.php";
     flashvars.logo = "top_right";
     flashvars.url_logo = "[var.base_url]/images/playerlogos/logo-player.png";
     flashvars.autoplay = "false";
     flashvars.color_nav_bar_top = "0xffffff";
     flashvars.color_nav_bar_bottom = "0x313131";
     flashvars.ads_background_color = "0x00CCFF";
     flashvars.ads_border_color = "0xCCCCCC";
     flashvars.scrubber_position_color = "0xffffff";
     flashvars.scrubber_load_color = "0x888888";
     flashvars.scrubber_background_color = "0xBBBBBB";
     flashvars.volume_bar_color = "0xBBBBBB";
     flashvars.buffering_time = 1;
     flashvars.aspect_ratio="stretch";
     params.allowfullscreen = "true";
     params.allowscriptaccess = "sameDomain";
     swfobject.embedSWF("[var.base_url]/player.swf", "myAlternativeContent", "710", "350", "9.0.0", false, flashvars, params, attributes);
   </script>
  </div>
 
  <!--End Video Player Container-->


this div contains the video player code now replace this div with the below code

<!--Video Player Container.  This is where the player embed code goes-->
  <div id="index-player-container">
 <script type="text/javascript" src="[var.base_url]/jwp/jwplayer.js"></script>
        <div id="myElement">Loading the player ...</div>
             <script type="text/javascript">
                    jwplayer("myElement").setup({
                                                    file: "[var.base_url]/uploads/[var.my_video_id].flv",
                                                    image: "[var.base_url]/uploads/thumbs/[var.my_video_id].jpg" ,
                                                    height: 350,
                                                    width: 710,
                                                    playlist: [[var.plist;htmlconv=no;]]
                                                   ,
                                          listbar: {
                                                      position: 'right',
                                                      size: 200
                                                   }
                                                });
            </script>
 </div>
   <!--End Video Player Container-->
   

for adding player at video play page you may apply similar code at play.php and inner_play.htm.

good day
    email this       edit

12 comments:

  1. Thanks for this, I plan to try it but I have a question. It appears that your code uses html5 mode for JWPlayer rather than Flash, is that correct? I'm wanting to use an HD/SD mod for PHPMotion that allows toggling between two versions of a video for faster or slower connections/PC's, and I'm wondering how difficult it would be to integrate that mod with your mod here.

    ReplyDelete
  2. hi,
    yes this post describe the integration of html5 version of jw player with phpmotion. if you really interested to integrate HD/SD mod for phpmotion I will prepare a post/tutorial for you.

    good day,
    hiren patel

    ReplyDelete
  3. That would be awesome, thank you!

    If I'm not mistaken, isn't the JWPlayer script capable of detecting when to use HTML5 and when to use flash? Is that capability included in your code above, or does it have to be done differently for that capability?

    Thanks.

    ReplyDelete
  4. I've succeeded so far in applying the HD/SD mod uploading code, so now my site generates an flv and an mp4 for each upload, but I'd like both files to be mp4 since the SD version may be up to 60 fps and this causes too high of a bitrate with flv/sorenson spark.

    ReplyDelete
  5. Hi again. Where do I add the code for play.php and inner_play.htm, and is it the exact same code as for inner_index.htm?

    Thanks.

    ReplyDelete
  6. Never mind, I think I'll wait till you post a tutorial for HD/SD so I can make all the changes at once.

    How soon do you think you can post the tutorial?

    Thanks!

    ReplyDelete
  7. hi
    i am preparing for the tutorial and most probably have demo of the tutorial.

    good day,
    hiren patel

    ReplyDelete
  8. This works well with Firefox, using flash player, but when I try it in Chrome, there's an error message saying that it couldn't load the html5 player, or that it wasn't found or something.

    Also, what about changing the player for the playlist?

    Please help! Thanks.

    ReplyDelete
  9. hi,
    sure,
    i need to check it out at your site.would you please mail me at renruhak@gmail.com

    ReplyDelete
  10. What files need to be changed to add player to play.php and inner_play.htm?

    Thanks!

    ReplyDelete
  11. hi
    wecome to my blog Rich. you need to change the inner_play.htm file for that.

    good day.
    Hiren Patel

    ReplyDelete

Hi, Thanks for the comment will try to reply at the earliest.

Good Day,
Hiren Patel
http://www.renruhak.org