Playing WMVs on Macs Playing WMVs on Macs
 

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

Playing WMVs on Macs

Started by Cyfarian, May 09, 2008, 12:57:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Cyfarian

The wmv files  won't play on Safari.  I went to microsoft's site about the issue: http://www.microsoft.com/windows/windowsmedia/howto/articles/macicp.aspx#embedding_the_player_in_a_web_page_

Here is the part I am focusing on...I am assuming that this will check for all macs to see if they have the plugin installed and if not, it will direct them to download it, right?  Now where in coppermine do I put the code below?  If that is not the proper code, can anyone kindly point me into the right direction?

Detecting the Player
You can write script for the Macintosh to verify that Windows Media Player is installed on the client computer. You can also check if the Player is installed on clients using Netscape Communicator 4.5 or later and Internet Explorer for Mac version 5 or later.

To check for the installation of Windows Media Player for Mac, use the following JavaScript code to check for the plug-in.

var fHasWMP = navigator.mimeTypes
              && navigator.mimeTypes["application/x-mplayer2"]
              && navigator.mimeTypes["application/x-mplayer2"].enabledPlugin;
if( fHasWMP ) {
    document.write("Windows Media Player is installed.");
}


Joachim Müller

The version on your page actually is cpg1.4.11, while the most recent stable release currently is cpg1.4.18. There are known security flaws in all versions before cpg1.4.18 that are actively being exploited, so upgrading instantly is mandatory no matter what.
If your operating system can't play WMVs, you have to figure this out on OS level - coppermine is just providing the file wrapped/embedded into the page output.

Cyfarian

Thanks for your response.  To clarify what I was asking about is if there is a way within coppermine to detect if someone on a mac has an applicable player for wmvs and if not to prompt them to download it.  I do not have a mac, so I have a hard time testing this.  I was just looking for some direction if there was a way to embed the code into coppermine and if not, if someone could kindly point me into the direction to resolve this.

I will upgrade.  Thank you.

Cyfarian

#4
Quote from: Cyfarian on May 09, 2008, 04:52:38 PM
Thanks for your response.  To clarify what I was asking about is if there is a way within coppermine to detect if someone on a mac has an applicable player for wmvs and if not to prompt them to download it.  I do not have a mac, so I have a hard time testing this.  I was just looking for some direction if there was a way to embed the code into coppermine and if not, if someone could kindly point me into the direction to resolve this.

I will upgrade.  Thank you.

I asked for help on a webdesign forum and someone was kind enough to provide the following javascript.  Is this something that I can plug into one of my coppermine files?  If so, which file and what line?  I suspect I will need to remove the first document write but other than that it looks okay to me.  Thoughts?

Thanks!!

Here is the script:

var fHasWMP = navigator.mimeTypes
              && navigator.mimeTypes["application/x-mplayer2"]
              && navigator.mimeTypes["application/x-
mplayer2"].enabledPlugin;
if( fHasWMP ) {
    document.write("Windows Media Player is installed.");
} else {

    document.write("Windows Media player not installed.  Go <a
href='http://www.flip4mac.com/wmv_upgrades.htm'>here</a> to download
it")

}

Joachim Müller

Needs to go into themes/yourtheme/theme.php, into the function definition for theme_html_picture(). Search your custom theme for the linefunction theme_html_picture()and edit as suggested below. If that line of code doesn't exist in your custom theme, 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=no,status=no,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['clsid'].$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);
}
from themes/sample/theme.php into a new line before?>of the file themes/yourtheme/theme.php

Then find        $pic_html  = '<object id="'.$player['id'].'" '.$player['clsid'].$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";
(that's the lines where the actual movie gets embedded) and modify the content of $pic_html accordingly.
However, the line you have posted above will just tell Mac users that they don't have the proper player, which doesn't make much sense to me: I guess that Mac users are aware that they can't view all types of Multimedia files out of the box, but they will have their reasons why they don't want Microsoft code to be installed on their boxes. Also note that your code relies on JavaScript, so you will need a <noscript>-tag as well.

Cyfarian

Joachim,
Thanks so much for your response.  I finally had time to upgrade to 1.4.18, switch from CoppermineVIS to Mehdi's bridge and look at the flip4mac issue.  I copied the theme_html_picture function into my theme.php.  I am not sure how to go about implementing the javascript inthe the pic_html area though.  Any thoughts on that?

As for your comment on the code just downloading flip4mac, do you have a better idea?  I could convert all of the videos to flash, but don't have time right now.