ajax link
<li class="video-li">
<a class="fancybox-video fancybox.ajax" href="<?php echo $this->getUrl('catalog/ajax/video') .'?attr=video_url_1&product_id='.$_product->getId();?>">
<img src="<?php
try {
echo (string)$_image_helper->init($_product, 'video_img_1')->resize(240,160);
} catch(Exception $e) {
;
}?>" />
</a>
</li>
<li class="video-li">
<a class="fancybox-video fancybox.ajax" href="<?php echo $this->getUrl('catalog/ajax/video') .'?attr=video_url_2&product_id='.$_product->getId();?>">
<img src="<?php
try {
echo (string)$_image_helper->init($_product, 'video_img_2')->resize(240,160);
} catch(Exception $e) {
;
}?>" />
</a>
</li>
fancy box:
$(".fancybox-video").fancybox({ 'padding' : 0, closeBtn:false, wrapCSS : 'share_container', });
3.custom ajax controller send param to phtml
<?php
class Bysoft_Mycatalog_AjaxController extends Mage_Core_Controller_Front_Action
{
public function shareAction(){
$this->loadLayout();
$this->renderLayout();
}
public function videoAction() {
/*
* catalog/product/view/video.phtml*/
$_attr = $_REQUEST['attr'];
$_product_id= $_REQUEST['product_id'];
$block = Mage::app()->getLayout()->getBlock('product_video');
$_product = Mage::getModel('catalog/product')->load($_product_id);
echo $this->getLayout()->createBlock('core/template')->setData('video',$_product->getData($_attr))->setTemplate('catalog/product/view/video.phtml')->toHtml();
}
3.custom phtml files: to load video player code
<video width="100%" height="auto" controls="controls" autoplay="autoplay" id="video">
<source src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'video/'.$this->getData('video');?>.mp4" type="video/mp4">
<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
name="mediaplayer1" ShowStatusBar="true" EnableContextMenu="false" autostart="false"
height="330" width="360" loop="false" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'video/'.$this->getData('video');?>.avi" />
</video>