Adding custom flv player to AttachMax

Its pretty simple to add and use custom player with AttachMax. I'll explain it on Jeroen Wijering's player example (we are using it on AttachMax.com now).

At first, please download Jeroen player and copy mediaplayer.swf to players/amJeroenPlayer/mediaplayer.swf and add bll/Player/Players/amJeroenPlayer.php file with following content:

<?php
class amJeroenPlayer extends amPlayer
{
    var $_sourcePath;

    function amJeroenPlayer()
    {
        parent::amPlayer();
        $this->setSourcePath(AM_PLAYER_DIR . '/amJeroenPlayer/' . 
            'mediaplayer.swf');
    }

    function getAutoPlayString ()
    {
        return $this->getAutoPlay() ? 'true' : 'false';
    }

    function getSourcePath()
    {
        return $this->_sourcePath;
    }

    function setSourcePath($value)
    {
        $this->_sourcePath = $value;
    }

    function getCustomParams()
    {
        return isset($GLOBALS[__CLASS__ . '_customParams']) ?
          $GLOBALS[__CLASS__ . '_customParams'] : array();
    }

    function setCustomParams($params)
    {
        $GLOBALS[__CLASS__ . '_customParams'] = $params;
    }

    function getHtml()
    {
        $p = amJeroenPlayer::getCustomParams();

        $flashVarsString = "file=" . $this->getVideoUrl();
        if (isset($p['FlashVars']))
        {
            foreach ($p['FlashVars'] as $k => $v)
            {
                $flashVarsString .= "&$k=$v";
            }
        }
        $flashVarsString .= '&autostart=' . $this->getAutoPlayString();

        $embedString = '';
        if (isset($p['embed']))
        {
            foreach ($p['embed'] as $k => $v)
            {
                $embedString .= " $k=\"$v\"";
            }
        }
        $embedString = '<embed src="' . $this->getSourcePath() .
            '" FlashVars="' . $flashVarsString . '" width="' .
            $this->getWidth() .
            '" height="' . $this->getHeight() . '" ' .
            $embedString . '>';

        return $embedString;
    }

}

Player class is ready, only few changes remained.

Open bll/Player/amPlayerFactory.php, find "function getExtensionsToPlayers()" and change "'flv' => 'amFlvPlayer'" to 'flv' => 'amJeroenPlayer'" under it. Then open configPlayers.php file and add:

amJeroenPlayer::setCustomParams(
    array(
       'embed' => array(
            'type' => 'application/x-shockwave-flash',
            'pluginspage' => 'http://www.macromedia.com/go/getflashplayer'
        ),

        'FlashVars' => array(
        )

    )
);

Jeroen player is ready to use now. To revert old player back you need to change single line in bll/Player/amPlayerFactory.php file, as we did for Jeroen player before.

For other, than Jeroen, flv player you can use same code with minor changes.

Please let me know, if you have any questions.

Alexander Makhaev

Comments

does this work with the

does this work with the shared version?

never mind. just figured it

never mind. just figured it out.

cool documentation. i thought i was stuck with Apple Quicktime to play mpeg videos.

thanks!

parse error

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/mhss7com/public_html/gallery/bll/Player/Players/amJeroenPlayer.php on line 15

i fixed the coding.check

i fixed the coding.

check where mediaplayer.swf' is. it should be 'mediaplayer.swf'

If you look closely, the first colon is missing before mediaplayer.swf

New Coding:

<?php
class amJeroenPlayer extends amPlayer
{
var $_sourcePath;

function amJeroenPlayer()
{
parent::amPlayer();
$this->setSourcePath(AM_PLAYER_DIR . '/amJeroenPlayer/' .
'mediaplayer.swf');
}

function getAutoPlayString ()
{
return $this->getAutoPlay() ? 'true' : 'false';
}

function getSourcePath()
{
return $this->_sourcePath;
}

function setSourcePath($value)
{
$this->_sourcePath = $value;
}

function getCustomParams()
{
return isset($GLOBALS[__CLASS__ . '_customParams']) ?
$GLOBALS[__CLASS__ . '_customParams'] : array();
}

function setCustomParams($params)
{
$GLOBALS[__CLASS__ . '_customParams'] = $params;
}

function getHtml()
{
$p = amJeroenPlayer::getCustomParams();

$flashVarsString = "file=" . $this->getVideoUrl();
if (isset($p['FlashVars']))
{
foreach ($p['FlashVars'] as $k => $v)
{
$flashVarsString .= "&$k=$v";
}
}
$flashVarsString .= '&autostart=' . $this->getAutoPlayString();

$embedString = '';
if (isset($p['embed']))
{
foreach ($p['embed'] as $k => $v)
{
$embedString .= " $k=\"$v\"";
}
}
$embedString = 'getSourcePath() .
'" FlashVars="' . $flashVarsString . '" width="' .
$this->getWidth() .
'" height="' . $this->getHeight() . '" ' .
$embedString . '>';

return $embedString;
}

}

Thanks!

Thanks for the player info!

Yes, it works with shared version too

Yes, it works with shared version too.

mcz101 wrote:
does this work with the shared version?

Thanks, code updated

Thanks, code updated.

mcz101 wrote:
i fixed the coding.

check where mediaplayer.swf' is. it should be 'mediaplayer.swf'

If you look closely, the first colon is missing before mediaplayer.swf

I don't know what happened

I made the changes above as descriped but this message came to me all the pages :

amJeroenPlayer::setCustomParams( array( 'embed' => array( 'type' => 'application/x-shockwave-flash', 'pluginspage' => 'http://www.macromedia.com/go/getflashplayer' ), 'FlashVars' => array( ) ) );

I tried to add the player

I tried to add the player from agriya.com and end up with a blank page.

I even get a blank page when

I even get a blank page when trying to add the Jeroen Wijering's player. It would be real nice to get some kind of help around here Sad

Windows Media Player?

How can I use windows media player for mp3 and wmv?
Although I changed "amPlayerFactory.php" with following code,
'wmv' => 'amWindowsMediaPlayer',
'mp3' => 'amWindowsMediaPlayer',
there is only blank space.
Is there someone know?
Please help me!

Thanks

Our player supports videos

Our player support videos only for now, mp3 is not video, so, you see blank space instead of player.

here is small how to if you

here is small how to if you want to make full screen active and add logo, make logo clickable and change player colors :

inside configPlayers.php add parameters or if you have not added any parameters just replace default

amJeroenPlayer::setCustomParams(
    array(
       'embed' => array(
            'type' => 'application/x-shockwave-flash',
            'pluginspage' => 'http://www.macromedia.com/go/getflashplayer'
        ),

        'FlashVars' => array(
        )

    )
);

------------

with

-----------

amJeroenPlayer::setCustomParams(
    array(
       'embed' => array(
            'type' => 'application/x-shockwave-flash',
            'pluginspage' => 'http://www.macromedia.com/go/getflashplayer',
   	   'allowfullscreen'=>'true'
        ),

        'FlashVars' => array(
        	'image'=>'http://yourdomain.com/cover.jpg',
            'frontcolor'=>'0x550000',
            'backcolor'=>'0xEEEEEE',
            'lightcolor'=>'0x000099',
            'logo'=>'http://yourdomain.com/watermark.jpg',
            'link'=>'http://yourdomain.com'
        )

    )
);

ERRORS

I love the concept of this player..
but I keep getting the following error:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/wamazoo/public_html/bll/Player/Players/amJeroenPlayer.php on line 62

any help?

THANKS!

Re: ERRORS

Please post lines 61-65 from your /home/wamazoo/public_html/bll/Player/Players/amJeroenPlayer.php here.

chris wrote:
I love the concept of this player.. but I keep getting the following error:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/wamazoo/public_html/bll/Player/Players/amJeroenPlayer.php on line 62

any help?

THANKS!

Logo bottom

Thank you for your code but on my page the logo is shown top and I would like to make it show bottom right.
I added a variable to realize this but it doesn't work.
Would you like to help me to do it? Thank's.