Your IP : 10.10.0.253


Current Path : /var/www/components/com_yendifvideoshare/models/
Upload File :
Current File : /var/www/components/com_yendifvideoshare/models/player.php

<?php
/**
 * @version    1.2.9
 * @package    Com_YendifVideoShare
 * @author     PluginsWare Interactive Pvt. Ltd <admin@yendifplayer.com>
 * @copyright  Copyright (c) 2012 - 2021 PluginsWare Interactive Pvt. Ltd. All Rights Reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

// Prevent direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

class YendifVideoShareModelPlayer extends YendifVideoShareModel {
    
    public function getItem() {
        $app = JFactory::getApplication();
        $db  = JFactory::getDbo();        

        $id   = $app->input->getInt( 'id' );
        $item = new stdClass();

        if ( $id > 0 ) {
            $query = 'SELECT * FROM #__yendifvideoshare_videos WHERE published=1 AND id=' . $id;
            $db->setQuery( $query );
            $item = $db->loadObject();
        }

        if ( empty( $item ) ) {
            $item->id = 0;
            $item->title = $app->get( 'sitename' );

            $sources = array( 'image', 'mp4', 'mp4_hd', 'webm', 'ogv', 'youtube', 'vimeo', 'hls', 'dash', 'captions' );

            foreach ( $sources as $source ) {
                $src = $app->input->get( $source, '', 'BASE64' );

                if ( empty( $src ) ) {
                    continue;
                }

                $src = base64_decode( $src );
                $item->{$source} = $src;

                switch ( $source ) {
                    case 'mp4':
                    case 'mp4_hd':
                    case 'webm':
                    case 'ogv':
                        $item->type = 'video';
                        break;
                    case 'youtube':
                        $item->type = 'youtube';

                        if ( ! isset( $item->image ) ) {
                            $item->image = YendifVideoShareUtils::getYouTubeVideoImage( $src );
                        }
                        break;
                    case 'vimeo':
                        $item->type = 'vimeo';

                        if ( ! isset( $item->image ) ) {
                            $item->image = YendifVideoShareUtils::getVimeoVideoImage( $src );
                        }
                        break;
                    case 'hls':
                    case 'dash':
                        $item->type = 'rtmp';
                        break;							
                }
            }
        }

        return $item;        
    }

    public function getParams() {
        $app = JFactory::getApplication();

        $params = $app->getParams();
        $config = YendifVideoShareUtils::getConfig();

        foreach ( $config as $option => $value ) {
            $__value = $params->get( $option, 'global' );

            if ( $__value == 'global' ) {
                $params->set( $option, $value );
            }
        }

        // Override if found in query params
        $options = array( 'autoplay', 'loop', 'playbtn', 'controlbar', 'playpause', 'currenttime', 'progress', 'duration', 'volumebtn', 'fullscreen', 'embed', 'share', 'autoplaylist' );
		foreach ( $options as $option ) {
			$value = $app->input->getInt( $option, -1 );

			if ( $value > -1 ) {
				$params->set( $option, $value );
			}
		}

        $volume = $app->input->getInt( 'volume' );
        if ( empty( $volume ) ) {
            $volume = (int) $config->volume;
        }
        $params->set( 'volume', $volume );

        return $params;
    }	
   
}