embed media player embed media player
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

embed media player

Started by Steve0019, March 15, 2006, 03:00:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Steve0019

hi, im new to this script and i like it a lot, its really neat, but i have a question. I am using coppermine 1.4.2. When you upload videos, you get this embed media player that will play the videos for you. Now i like it, but its too plain.' I want to add the code that shows you the bar that says it is buffering and shows u the percent, then when it plays, it tells you the fvideo name, what speed its playing at, the author etc. If you go to www.putfile.com and look at there embed media player, that what i mean. I know how to add this code into it to add that bar, but i can't find where to change it. Do any of you guys have any idea when i can edit the media player code so this will work. I want this b/c everyone says that the video wont load, which really it is, it just takes forver. This bar will tell you that the video is buffering, so my visitors know its working. Hope someone has done this and can help...

Joachim Müller

coppermine doesn't come with a media player, it uses the one that exists on your client (on Windows usually Windows Media Player).

Steve0019

i know, but its the same as those other sites like putfile, or my old site, socomvideos.com... it an code that calls the media plaer on your computer to play on that page, but there is ways to change the appearence like add that bar, but i guess there no where in any of the coppermine files that allows you to edit that

like here is an example of the code i use on my old site that calls the media player onto the page

<object id="MediaPlayer1" height="240" width="300" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows® Media Player components..." type="application/x-oleobject">
<param name="enablecontextmenu" value="false">
<param name="URL" value="http://www.socomvideos.com/videos/socomvideos.com-5.wmv?fileid=http://www.socomvideos.com/videos/socomvideos.com-5.wmv">
<param name="showcontrols" value="true"><embed height="240" width="300" src="http://www.socomvideos.com/videos/socomvideos.com-5.wmv?fileid=http://www.socomvideos.com/videos/socomvideos.com-5.wmv" showcontrols=1 pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="MediaPlayer1" autostart=1 type="application/x-mplayer2"></embed></object>

i could be wrong, but if there something like that in any files, please let me know

Joachim Müller

edit themes/yourtheme/theme.php, findfunction theme_html_picture()and modify accordingly. If your custom theme doesn't contain that line, copy// Displays a picture
function theme_html_picture()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER;
    global $album, $comment_date_fmt, $template_display_media;
    global $lang_display_image_php, $lang_picinfo;

    $pid = $CURRENT_PIC_DATA['pid'];
    $pic_title = '';

    if (!isset($USER['liv']) || !is_array($USER['liv'])) {
        $USER['liv'] = array();
    }
    // Add 1 to hit counter
    if (!USER_IS_ADMIN && !in_array($pid, $USER['liv']) && isset($_COOKIE[$CONFIG['cookie_name'] . '_data'])) {
        add_hit($pid);
        if (count($USER['liv']) > 4) array_shift($USER['liv']);
        array_push($USER['liv'], $pid);
    }

    if($CONFIG['thumb_use']=='ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width'] ){ // The wierd comparision is because only picture_width is stored
      $condition = true;
    }elseif($CONFIG['thumb_use']=='wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']){
      $condition = true;
    }elseif($CONFIG['thumb_use']=='any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']){
      $condition = true;
    }else{
     $condition = false;
    }

    if ($CURRENT_PIC_DATA['title'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['title'] . "\n";
    }
    if ($CURRENT_PIC_DATA['caption'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['caption'] . "\n";
    }
    if ($CURRENT_PIC_DATA['keywords'] != '') {
        $pic_title .= $lang_picinfo['Keywords'] . ": " . $CURRENT_PIC_DATA['keywords'];
    }

    if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) {
        template_extract_block($template_display_media, 'img_desc');
    } else {
        if (!$CURRENT_PIC_DATA['title']) {
            template_extract_block($template_display_media, 'title');
        }
        if (!$CURRENT_PIC_DATA['caption']) {
            template_extract_block($template_display_media, 'caption');
        }
    }

    $CURRENT_PIC_DATA['menu'] = html_picture_menu(); //((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || ($CONFIG['users_can_edit_pics'] && $CURRENT_PIC_DATA['owner_id'] == USER_ID && USER_ID != 0) || GALLERY_ADMIN_MODE) ? html_picture_menu($pid) : '';

    if ($CONFIG['make_intermediate'] && $condition ) {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal');
    } else {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize');
    }

    $image_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $CONFIG['picture_width']);

    $pic_title = '';
    $mime_content = cpg_get_type($CURRENT_PIC_DATA['filename']);


    if ($mime_content['content']=='movie' || $mime_content['content']=='audio') {

        if ($CURRENT_PIC_DATA['pwidth']==0 || $CURRENT_PIC_DATA['pheight']==0) {
            $CURRENT_PIC_DATA['pwidth']  = 320; // Default width

            // Set default height; if file is a movie
            if ($mime_content['content']=='movie') {
                $CURRENT_PIC_DATA['pheight'] = 240; // Default height
            }
        }

        $ctrl_offset['mov']=15;
        $ctrl_offset['wmv']=45;
        $ctrl_offset['swf']=0;
        $ctrl_offset['rm']=0;
        $ctrl_offset_default=45;
        $ctrl_height = (isset($ctrl_offset[$mime_content['extension']]))?($ctrl_offset[$mime_content['extension']]):$ctrl_offset_default;
        $image_size['whole']='width="'.$CURRENT_PIC_DATA['pwidth'].'" height="'.($CURRENT_PIC_DATA['pheight']+$ctrl_height).'"';
    }

    if ($mime_content['content']=='image') {
        if (isset($image_size['reduced'])) {
            $winsizeX = $CURRENT_PIC_DATA['pwidth']+5;  //the +'s are the mysterious FF and IE paddings
            $winsizeY = $CURRENT_PIC_DATA['pheight']+3; //the +'s are the mysterious FF and IE paddings
            $pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=yes,status=yes,resizable=yes,width=$winsizeX,height=$winsizeY')\">";
            $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title;
            $pic_html .= "<img src=\"" . $picture_url . "\" class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
            $pic_html .= "</a>\n";
        } else {
            $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n";
        }
    } elseif ($mime_content['content']=='document') {
        $pic_thumb_url = get_pic_url($CURRENT_PIC_DATA,'thumb');
        $pic_html = "<a href=\"{$picture_url}\" target=\"_blank\" class=\"document_link\"><img src=\"".$pic_thumb_url."\" border=\"0\" class=\"image\" /></a>\n<br />";
    } else {
        $autostart = ($CONFIG['media_autostart']) ? ('true'):('false');

        $players['WMP'] = array('id' => 'MediaPlayer',
                                'clsid' => 'classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" ',
                                'codebase' => 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ',
                                'mime' => 'type="application/x-mplayer2" ',
                               );
        $players['RMP'] = array('id' => 'RealPlayer',
                                'clsid' => 'classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" ',
                                'codebase' => '',
                                'mime' => 'type="audio/x-pn-realaudio-plugin" '
                               );
        $players['QT']  = array('id' => 'QuickTime',
                                'clsid' => 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ',
                                'codebase' => 'codebase="http://www.apple.com/qtactivex/qtplugin.cab" ',
                                'mime' => 'type="video/x-quicktime" '
                               );
        $players['SWF'] = array('id' => 'SWFlash',
                                'clsid' => ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ',
                                'codebase' => 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ',
                                'mime' => 'type="application/x-shockwave-flash" '
                               );
        $players['UNK'] = array('id' => 'DefaultPlayer',
                                'clsid' => '',
                                'codebase' => '',
                                'mime' => ''
                               );

        if (isset($_COOKIE[$CONFIG['cookie_name'].'_'.$mime_content['extension'].'player'])) {
            $user_player = $_COOKIE[$CONFIG['cookie_name'].'_'.$mime_content['extension'].'player'];
        } else {
            $user_player = $mime_content['player'];
        }

                // There isn't a player selected or user wants client-side control
        if (!$user_player) {
            $user_player = 'UNK';
        }

        $player = $players[$user_player];

        $pic_html  = '<object id="'.$player['id'].'" '.$player['classid'].$player['codebase'].$player['mime'].$image_size['whole'].'>';
        $pic_html .= "<param name=\"autostart\" value=\"$autostart\" /><param name=\"src\" value=\"". $picture_url . "\" />";
        $pic_html .= '<embed '.$image_size['whole'].' src="'. $picture_url . '" autostart="'.$autostart.'" '.$player['mime'].'></embed>';
        $pic_html .= "</object><br />\n";
    }

    $CURRENT_PIC_DATA['html'] = $pic_html;
    $CURRENT_PIC_DATA['header'] = '';
    $CURRENT_PIC_DATA['footer'] = '';

    $CURRENT_PIC_DATA = CPGPluginAPI::filter('file_data',$CURRENT_PIC_DATA);

    $params = array('{CELL_HEIGHT}' => '100',
        '{IMAGE}' => $CURRENT_PIC_DATA['header'].$CURRENT_PIC_DATA['html'].$CURRENT_PIC_DATA['footer'],
        '{ADMIN_MENU}' => $CURRENT_PIC_DATA['menu'],
        '{TITLE}' => bb_decode($CURRENT_PIC_DATA['title']),
        '{CAPTION}' => bb_decode($CURRENT_PIC_DATA['caption']),
        );

    return template_eval($template_display_media, $params);
}
into a new line right before ?>(code taken from themes/sample/theme.php). The section to look at is        $pic_html  = '<object id="'.$player['id'].'" '.$player['classid'].$player['codebase'].$player['mime'].$image_size['whole'].'>';
        $pic_html .= "<param name=\"autostart\" value=\"$autostart\" /><param name=\"src\" value=\"". $picture_url . "\" />";
        $pic_html .= '<embed '.$image_size['whole'].' src="'. $picture_url . '" autostart="'.$autostart.'" '.$player['mime'].'></embed>';
        $pic_html .= "</object><br />\n";

Steve0019

thanks for the help, i just want the media player to look just like the one on my old site with some of that html code i posted in here, but i dont know where to add it in the code sample you just showed me. if you can't help no more, its ok thanks

Joachim Müller

try         $pic_html  = '<object id="'.$player['id'].'" '.$player['classid'].$player['codebase'].$player['mime'].$image_size['whole'].'>';
        $pic_html .= '<param name="enablecontextmenu" value="false">';
        $pic_html .= "<param name=\"autostart\" value=\"$autostart\" />";
        $pic_html .= '<param name="URL" value="'. $picture_url .'" />';
        $pic_html .= '<param name="showcontrols" value="true" />';
        $pic_html .= "<param name=\"src\" value=\"". $picture_url . "\" />";
        $pic_html .= '<embed '.$image_size['whole'].' src="'. $picture_url . '" autostart="'.$autostart.'" '.$player['mime'].' showcontrols=1 pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"></embed>';
        $pic_html .= "</object><br />\n";
then...

Steve0019

hey, i got it to work, i used your first code help and figured it out. I wanted to show the status bar in the media player so visitors know if the video is buffering. I got it to work and thank you very much for helping. Here is the code i used.

You gave me
  $pic_html  = '<object id="'.$player['id'].'" '.$player['classid'].$player['codebase'].$player['mime'].$image_size['whole'].'>';
        $pic_html .= "<param name=\"autostart\" value=\"$autostart\" /><param name=\"src\" value=\"". $picture_url . "\" />";
        $pic_html .= '<embed '.$image_size['whole'].' src="'. $picture_url . '" autostart="'.$autostart.'" '.$player['mime'].'></embed>';
        $pic_html .= "</object><br />\n";


And i modifed it to this
$pic_html  = '<object id="'.$player['id'].'" '.$player['classid'].$player['codebase'].$player['mime'].$image_size['whole'].'>';
        $pic_html .= "<param name=\"autostart\" value=\"$autostart\" /><param name=\"enablecontextmenu\" value=\"false\" /><param name=\"showcontrols\" value=\"true\" /><param name=\"ShowStatusBar\" value=\"True\" /><param name=\"src\" value=\"". $picture_url . "\" />";
        $pic_html .= '<embed '.$image_size['whole'].' src="'. $picture_url . '" autostart="'.$autostart.'" '.$player['mime'].'></embed>';
        $pic_html .= "</object><br />\n";


It works great now. To see what i am talking about, go to this link below. It my site with the add on to the media player. Its the status bar. (It only works in IE, not firefox, so if your using firefox, load up the link in IE to see what i am talking about)

http://socomvideos.com/home/displayimage.php?album=3&pos=0

Joachim Müller

*sigh* that's why we try to avoid proprietary code... ;)

slausen

Thanks a lot for this info!

I was looking for a way to do this, just tried it and it works!  :D

One thing is that I had to add some extra data into the "mime" variable to get it to work like yours Steve...


$players['WMP'] = array('id' => 'MediaPlayer',^M
// rm'd to enable visible buffering, added extras in mime for WMP  'clsid' => 'classid="" ',^M
'clsid' => 'classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" ',^M
'codebase' => 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ',^M
'mime' => 'type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="mediaplayer1" showstatusbar="1" EnableContextMenu="false" '^M
   );^M


For some reason there was no CLSID for WMP in my code, I recently downloaded 1.4.4 so that may be a bug in the code currently  available for download on the site.

slausen

Quote from: GauGau on March 15, 2006, 10:12:53 AM
*sigh* that's why we try to avoid proprietary code... ;)

Steve's link works for me in Firefox.

cavallino

thanks for this ...
anyway this works good with wmv and other windows type of movies which can be buffered correctly depending on codecs insalled.
Instead, if i put for example an avi of 40 MB the page gets stuck until it loads completely the movie, and only after that you can play the movie... when the page loads and the only way to exit that situation is to terminate the browser from the application tasks.

So I kindly ask if there is any way to disable the load of the movies or completely delete the embedded media player. Which parts i have to modify to accomplish this?

Thanks, hope u can help

Steve0019

oh cool, it does work in firefox, nvm then... This was something i wanted to do and im glad i got it working, thanks a lot.

As for deleting the media player, im not sire that is going to work, i tryed deleteing the code for the media player that GauGau gave me and it wouldn't load the displayimage.php it was just a blank screen, so that means it might now work. You should just offer a download link for those movies.

slausen

Quote from: cavallino on March 15, 2006, 12:53:42 PM
thanks for this ...
anyway this works good with wmv and other windows type of movies which can be buffered correctly depending on codecs insalled.
Instead, if i put for example an avi of 40 MB the page gets stuck until it loads completely the movie, and only after that you can play the movie... when the page loads and the only way to exit that situation is to terminate the browser from the application tasks.

So I kindly ask if there is any way to disable the load of the movies or completely delete the embedded media player. Which parts i have to modify to accomplish this?

Thanks, hope u can help

There is a config setting in CPG 1.4.4 that lets you turn off "autostart" of the movie playback, but I have noticed thatFirefox ignores this setting and always starts playback on my machine. But on IE and Opera it seems to work. Also, making the changes outlined by Steve, seems to enable the "Stop" button in the media player (so if a user presses it, the download of the movie file will stop).

There is also a mod (I think by Stramm) that lets you add a "Download" link to CPG's movie file display page.

Steve0019

yea, if you go to the link i posted to show you my site with the workin media player, i have a download link in there too.. That media  player will only buffer wmv movie formats. For all mpg, mpeg, and avi.. it just plays it at the start and skipps. I run a site that is dedicated to gamers of Socom Us Navy Seals (its a video game for the PS2 gaming system) People use capture cards and record themselves playing and i provide them with archives to host there videos in. Most of the video they capture are saved in WMV format, so it works great for me