Пример #1
0
    /**
     * get all video support type, ex. array(1=>youtube, 2=>vimeo)
     * @param string $return_key choose: name or title
     * @return array [id=>name]
     * 
     */
    public static function getAllSupportTypes($return_key = 'title') {

        if (NULL === self::$_supportTypes) {
            self::$_supportTypes = array(
                1 => array('name' => 'youtube', 'title' => 'YouTube Video'),
                2 => array('name' => 'vimeo', 'title' => 'Vimeo Video'),
                self::$_uploadedType => array('name' => 'uploaded', 'title' => 'My Computer'), // mean '3'
                4 => array('name' => 'dailymotion', 'title' => 'Dailymotion Video'),
                self::$_videoUrlType => array('name' => 'videoURL', 'title' => 'URL Video'), // mean '5'
                6 => array('name' => 'embed', 'title' => 'Embed Video') 
            );
        }

        $ret = array();
        foreach (self::$_supportTypes as $key => $row) {
            $ret[$key] = $row[$return_key];
        }
        return $ret;
    }
Пример #2
0
    public function init() {
        $this->clearDecorators()
                ->addDecorator('FormElements')
                ->addDecorator('Form')
                ->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'search'))
                ->addDecorator('HtmlTag2', array('tag' => 'div', 'class' => 'clear'));

        $this->setAttribs(array('id' => 'filter_form', 'class' => 'global_form_box'))->setMethod('get');

        //Search Title
        $this->addElement('Text', 'title', array(
            'label' => 'Title',
        ));

        //Search Owner
        $this->addElement('Text', 'owner', array(
            'label' => 'Owner',
        ));

        //Feature
        $this->addElement('Select', 'featured', array(
            'label' => 'Featured',
            'multiOptions' => array(
                '' => '',
                '0' => 'Only Featured Videos',
                '1' => 'Only Not Featured Videos',
            ),
            'value' => '',
        ));

        //Feature
        $this->addElement('Select', 'featured', array(
            'label' => 'Featured',
            'multiOptions' => array(
                '' => '',
                '1' => 'Only Featured Videos',
                '0' => 'Only Not Featured Videos',
            ),
            'value' => '',
        ));

        $videoTypes[''] = '';
        foreach (Ynvideo_Plugin_Factory::getAllSupportTypes() as $key => $type) {
            $videoTypes[$key] = $type;
        }

        //Feature
        $this->addElement('Select', 'type', array(
            'label' => 'Type',
            'multiOptions' => $videoTypes,
            'value' => '',
        ));

        // Buttons
        $this->addElement('Button', 'button', array(
            'label' => 'Search',
            'type' => 'submit',
        ));

        $this->button->clearDecorators()
                ->addDecorator('ViewHelper')
                ->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'buttons'))
                ->addDecorator('HtmlTag2', array('tag' => 'div'));
    }
Пример #3
0
 public function fetchVideoLargeThumbnail($videos = null) 
 {        
     if ($videos) {            
         if ($videos instanceof Ynvideo_Model_Video) {
             $arrVideos = array($videos);
         } else {
             $arrVideos = $videos;
         }
     }
     if ($arrVideos) {
         foreach ($arrVideos as $video) {
             if (!$video->large_photo_id) {
                 $adapter = Ynvideo_Plugin_Factory::getPlugin($video->type);
                 $adapter->setParams(array('code' => $video->code, 'video_id' => $video->getIdentity()));                    
                 $video->storeThumbnail($adapter->getVideoLargeImage(), 'large');
             }
         }
     }
 }
Пример #4
0
	public function popupViewAction()
	{
		$video_id = $this -> _getParam('video_id');
		$video = Engine_Api::_() -> getItem('video', $video_id);
		if ($video)
		{
			Engine_Api::_() -> core() -> setSubject($video);
		}
		if (!$this -> _helper -> requireSubject() -> isValid())
		{
			return;
		}
		$type = $video -> getType();

		$video = Engine_Api::_() -> core() -> getSubject('video');
		$viewer = Engine_Api::_() -> user() -> getViewer();

		//Get Photo Url
		$photoUrl = $video -> getPhotoUrl('thumb.normal');
		$pos = strpos($photoUrl, "http");
		if ($pos === false)
		{
			$photoUrl = rtrim((constant('_ENGINE_SSL') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'], '/') . $photoUrl;
		}

		//Get Video Url
		$videoUrl = $video -> getHref();
		$pos = strpos($videoUrl, "http");
		if ($pos === false)
		{
			$videoUrl = rtrim((constant('_ENGINE_SSL') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'], '/') . $videoUrl;
		}

		$watchLaterTbl = Engine_Api::_() -> getDbTable('watchlaters', 'ynvideo');
		$watchLaterTbl -> update(array(
			'watched' => '1',
			'watched_date' => date('Y-m-d H:i:s')
		), array(
			"video_id = {$video->getIdentity()}",
			"user_id = {$viewer->getIdentity()}"
		));

		// Check if edit/delete is allowed
		$this -> view -> can_edit = $can_edit = $this -> _helper -> requireAuth() -> setAuthParams($video, null, 'edit') -> checkRequire();
		$this -> view -> can_delete = $can_delete = $this -> _helper -> requireAuth() -> setAuthParams($video, null, 'delete') -> checkRequire();
		$embedded = "";
		// increment count
		if ($video -> status == 1)
		{
			if (!$video -> isOwner($viewer))
			{
				$video -> view_count++;
				$video -> save();
				Engine_Api::_()->getDbTable('views', 'ynvideo')->addView($video);
			}
            $embedded = $video -> getRichContent(true);
		}

		if ($video -> type == Ynvideo_Plugin_Factory::getUploadedType() && $video -> status == 1)
		{
			$session = new Zend_Session_Namespace('mobile');
			$responsive_mobile = FALSE;
			if (defined('YNRESPONSIVE'))
			{
				$responsive_mobile = Engine_Api::_()-> ynresponsive1() -> isMobile();
			}
			if (!empty($video -> file1_id))
			{
				$storage_file = Engine_Api::_() -> getItem('storage_file', $video -> file_id);
				if ($session -> mobile || $responsive_mobile)
				{
					$storage_file = Engine_Api::_() -> getItem('storage_file', $video -> file1_id);
				}
				if ($storage_file)
				{
					$this -> view -> video_location1 = $storage_file -> map();
					$this -> view -> video_location = '';
				}
			}
			else 
			{
				$storage_file = Engine_Api::_() -> getItem('storage_file', $video -> file_id);
				if ($storage_file)
				{
					$this -> view -> video_location = $storage_file -> map();
					$this -> view -> video_location1 = '';
				}
			}
		}
		else
		if ($video -> type == Ynvideo_Plugin_Factory::getVideoURLType())
		{
			$this -> view -> video_location = $video -> code;
		}

		$settings = Engine_Api::_() -> getApi('settings', 'core');
		$this -> view -> numberOfEmail = $settings -> getSetting('ynvideo.friend.emails', 5);
		$this -> view -> viewer_id = $viewer -> getIdentity();
		$this -> view -> rating_count = Engine_Api::_() -> ynvideo() -> ratingCount($video -> getIdentity());
		$this -> view -> video = $video;
		$this -> view -> rated = Engine_Api::_() -> ynvideo() -> checkRated($video -> getIdentity(), $viewer -> getIdentity());
		$this -> view -> videoEmbedded = $embedded;
	}
Пример #5
0
					throw new Ynvideo_Model_Exception('Video temporary directory did not exist and could not be created.');
				}
			}
			if (!is_writable($tmpDir))
			{
				throw new Ynvideo_Model_Exception('Video temporary directory is not writable.');
			}

			if (!($video instanceof Ynvideo_Model_Video))
			{
				throw new Ynvideo_Model_Exception('Argument was not a valid video');
			}

			// Update to encoding status
			$video -> status = 2;
			$video -> type = Ynvideo_Plugin_Factory::getUploadedType();
			$video -> save();

			// Prepare information
			$owner = $video -> getOwner();
			$filetype = $video -> code;

			// Pull video from storage system for encoding
			$storageObject = Engine_Api::_() -> getItem('storage_file', $video -> file_id);
			if (!$storageObject)
			{
				throw new Ynvideo_Model_Exception('Video storage file was missing');
			}

			$originalPath = $storageObject -> temporary();
			if (!file_exists($originalPath))
Пример #6
0
    protected function _process($video)
    {
        // Make sure FFMPEG path is set
        $ffmpeg_path = Engine_Api::_() -> getApi('settings', 'core') -> ynvideo_ffmpeg_path;
        if (!$ffmpeg_path)
        {
            throw new Ynvideo_Model_Exception('Ffmpeg not configured');
        }
        // Make sure FFMPEG can be run
        if (!@file_exists($ffmpeg_path) || !@is_executable($ffmpeg_path))
        {
            $output = null;
            $return = null;
            exec($ffmpeg_path . ' -version', $output, $return);
            if ($return > 0)
            {
                throw new Ynvideo_Model_Exception('Ffmpeg found, but is not executable');
            }
        }

        // Check we can execute
        if (!function_exists('shell_exec'))
        {
            throw new Ynvideo_Model_Exception('Unable to execute shell commands using shell_exec(); the function is disabled.');
        }

        // Check the video temporary directory
        $tmpDir = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'temporary' . DIRECTORY_SEPARATOR . 'video';
        if (!is_dir($tmpDir))
        {
            if (!mkdir($tmpDir, 0777, true))
            {
                throw new Ynvideo_Model_Exception('Video temporary directory did not exist and could not be created.');
            }
        }
        if (!is_writable($tmpDir))
        {
            throw new Ynvideo_Model_Exception('Video temporary directory is not writable.');
        }

        // Get the video object
        if (is_numeric($video))
        {
            $video = Engine_Api::_() -> getItem('video', $video_id);
        }

        if (!($video instanceof Ynvideo_Model_Video))
        {
            throw new Ynvideo_Model_Exception('Argument was not a valid video');
        }

        // Update to encoding status
        $video -> status = 2;
        $video -> type = Ynvideo_Plugin_Factory::getUploadedType();
        $video -> save();

        // Prepare information
        $owner = $video -> getOwner();
        $filetype = $video -> code;

        // Pull video from storage system for encoding
        $storageObject = Engine_Api::_() -> getItem('storage_file', $video -> file_id);
        if (!$storageObject)
        {
            throw new Ynvideo_Model_Exception('Video storage file was missing');
        }

        $originalPath = $storageObject -> temporary();
        if (!file_exists($originalPath))
        {
            throw new Ynvideo_Model_Exception('Could not pull to temporary file'); 
        }

        $outputPath = $tmpDir . DIRECTORY_SEPARATOR . $video -> getIdentity() . '_vconverted.mp4';
        $thumbPathLarge = $tmpDir . DIRECTORY_SEPARATOR . $video -> getIdentity() . '_vthumb_large.jpg';
        $thumbPath = $tmpDir . DIRECTORY_SEPARATOR . $video -> getIdentity() . '_vthumb.jpg';

        //Convert to Mp4 (h264 - HTML5, mpeg4 - IOS)
        
        $videoCommand = $ffmpeg_path . ' '
          . '-i ' . escapeshellarg($originalPath) . ' '
          . '-ab 64k' . ' '
          . '-ar 44100' . ' '
          . '-qscale 5' . ' '
          . '-r 25' . ' ';
    
        $videoCommand .= '-vcodec libx264' . ' '
          . '-acodec aac' . ' '
          . '-strict experimental' . ' '
          . '-preset veryfast' . ' '
          . '-f mp4' . ' ';
          
        $videoCommand .= "-s 640x360" . ' ';
         
        $videoCommand .=
          '-y ' . escapeshellarg($outputPath) . ' '
          . '2>&1';
        
        // Prepare output header 
        $output = PHP_EOL;
        $output .= $originalPath . PHP_EOL;
        $output .= $outputPath . PHP_EOL;
        $output .= $thumbPathLarge . PHP_EOL;

        // Execute video encode command
        $videoOutput = $output . $videoCommand . PHP_EOL . shell_exec($videoCommand);
        // Check for failure
        $success = true;

        // Unsupported format
        if (preg_match('/Unknown format/i', $videoOutput) || preg_match('/Unsupported codec/i', $videoOutput) || preg_match('/patch welcome/i', $videoOutput) || preg_match('/Audio encoding failed/i', $videoOutput) || !is_file($outputPath) || filesize($outputPath) <= 0)
        {
            $success = false;
            $video -> status = 3;
        }

        // This is for audio files
        else
        if (preg_match('/video:0kB/i', $videoOutput))
        {
            $success = false;
            $video -> status = 5;
        }

        // Failure
        if (!$success)
        {
            $exceptionMessage = '';
            $db = $video -> getTable() -> getAdapter();
            $db -> beginTransaction();
            try
            {
                $video -> save();

                // notify the owner
                $translate = Zend_Registry::get('Zend_Translate');
                $language = (!empty($owner -> language) && $owner -> language != 'auto' ? $owner -> language : null);
                $notificationMessage = '';

                if ($video -> status == 3)
                {
                    $exceptionMessage = 'Video format is not supported by FFMPEG.';
                    $notificationMessage = $translate -> translate(sprintf('Video conversion failed. Video format is not supported by FFMPEG. Please try %1$sagain%2$s.', '', ''), $language);
                }
                else
                if ($video -> status == 5)
                {
                    $exceptionMessage = 'Audio-only files are not supported.';
                    $notificationMessage = $translate -> translate(sprintf('Video conversion failed. Audio files are not supported. Please try %1$sagain%2$s.', '', ''), $language);
                }
                else
                {
                    $exceptionMessage = 'Unknown encoding error.';
                }

                Engine_Api::_() -> getDbtable('notifications', 'activity') -> addNotification($owner, $owner, $video, 'ynvideo_processed_failed', array(
                    'message' => $notificationMessage,
                    'message_link' => Zend_Controller_Front::getInstance() -> getRouter() -> assemble(array('action' => 'manage'), 'video_general', true),
                ));

                $db -> commit();
            }
            catch (Exception $e)
            {
                $videoOutput_mpeg4 .= PHP_EOL . $e -> __toString() . PHP_EOL;
                $db -> rollBack();
            }

            // Write to additional log in dev
            if (APPLICATION_ENV == 'development')
            {
                file_put_contents($tmpDir . '/' . $video -> video_id . '.txt', $videoOutput);
            }

            throw new Ynvideo_Model_Exception($exceptionMessage);
        }

        // Success
        else
        {
            // Get duration of the video to caculate where to get the thumbnail
            if (preg_match('/Duration:\s+(.*?)[.]/i', $videoOutput, $matches))
            {
                list($hours, $minutes, $seconds) = preg_split('[:]', $matches[1]);
                $duration = ceil($seconds + ($minutes * 60) + ($hours * 3600));
            }
            else
            {
                $duration = 0;
                // Hmm
            }

            // Fetch where to take the thumbnail
            $thumb_splice = $duration / 2;

            // Thumbnail proccess command
            $thumbCommand = $ffmpeg_path . ' ' . '-i ' . escapeshellarg($outputPath) . ' ' . '-f image2' . ' ' . '-ss ' . $thumb_splice . ' ' . '-vframes ' . '1' . ' ' . '-v 2' . ' ' . '-y ' . escapeshellarg($thumbPath) . ' ' . '2>&1';

            // Process thumbnail
            $thumbOutput = $output . $thumbCommand . PHP_EOL . shell_exec($thumbCommand);

            // Check output message for success
            $thumbSuccess = true;
            if (preg_match('/video:0kB/i', $thumbOutput))
            {
                $thumbSuccess = false;
            }

            // Resize thumbnail
            if ($thumbSuccess)
            {
                try
                {
                    $image = Engine_Image::factory();
                    $image -> open($thumbPath) -> resize(640, 360) -> write($thumbPathLarge) -> destroy();
                    $image -> open($thumbPath) -> resize(120, 240) -> write($thumbPath) -> destroy();
                }
                catch (Exception $e)
                {
                    $this -> _addMessage((string)$e -> __toString());
                    $thumbSuccess = false;
                }
            }

            // Save video and thumbnail to storage system
            $params = array(
                'parent_id' => $video -> getIdentity(),
                'parent_type' => $video -> getType(),
                'user_id' => $video -> owner_id
            );

            $db = $video -> getTable() -> getAdapter();
            $db -> beginTransaction();

            try
            {
                $storageObject -> setFromArray($params);
                $storageObject -> store($outputPath);

                if ($thumbSuccess)
                {
                    $thumbFileRowLarge = Engine_Api::_() -> storage() -> create($thumbPathLarge, $params);
                    $thumbFileRow = Engine_Api::_() -> storage() -> create($thumbPath, $params);
                }
				
                $db -> commit();
            }
            catch (Exception $e)
            {
                $db -> rollBack();

                // delete the files from temp dir
                unlink($originalPath);
                unlink($outputPath);

                if ($thumbSuccess)
                {
                    unlink($thumbPathLarge);
                    unlink($thumbPath);
                }

                $video -> status = 7;
                $video -> save();

                // notify the owner
                $translate = Zend_Registry::get('Zend_Translate');
                $notificationMessage = '';
                $language = (!empty($owner -> language) && $owner -> language != 'auto' ? $owner -> language : null);
                if ($video -> status == 7)
                {
                    $notificationMessage = $translate -> translate(sprintf('Video conversion failed. You may be over the site upload limit.  Try %1$suploading%2$s a smaller file, or delete some files to free up space.', '', ''), $language);
                }
                Engine_Api::_() -> getDbtable('notifications', 'activity') -> addNotification($owner, $owner, $video, 'ynvideo_processed_failed', array(
                    'message' => $notificationMessage,
                    'message_link' => Zend_Controller_Front::getInstance() -> getRouter() -> assemble(array('action' => 'manage'), 'video_general', true),
                ));

                //throw $e;
                // throw
            }

            // Video processing was a success!
            // Save the information
            if ($thumbSuccess)
            {
                $video -> photo_id = $thumbFileRow -> file_id;
                $video -> large_photo_id = $thumbFileRowLarge -> file_id;
            }
            $video -> file1_id = $video -> file_id;
            $video -> duration = $duration;
            $video -> status = 1;
            $video -> save();
			
			// notify the owner
            Engine_Api::_() -> getDbtable('notifications', 'activity') -> addNotification($owner, $owner, $video, 'ynvideo_processed');

            // delete the files from temp dir
            unlink($originalPath);
            unlink($outputPath);

            unlink($thumbPathLarge);
            unlink($thumbPath);

            // insert action in a seperate transaction if video status is a success
            $actionsTable = Engine_Api::_() -> getDbtable('actions', 'activity');
            $db = $actionsTable -> getAdapter();
            $db -> beginTransaction();

            try
            {
                // new action
                $item = Engine_Api::_() -> getItem($video -> parent_type, $video -> parent_id);
                if ($video -> parent_type == 'group')
                {
                    $action = $actionsTable -> addActivity($owner, $item, 'advgroup_video_create');
                }
                elseif ($video -> parent_type == 'event')
                {
                    $action = $actionsTable -> addActivity($owner, $item, 'ynevent_video_create');
                }
                else
                {
                    $action = $actionsTable -> addActivity($owner, $video, 'video_new');
                }
                if ($action)
                {
                    $actionsTable -> attachActivity($action, $video);
                }

                $db -> commit();
            }
            catch (Exception $e)
            {
                $db -> rollBack();
                //throw $e;
                // throw
            }
        }
    }
Пример #7
0
	public function getRichContent($view = false, $params = array())
	{
		$session = new Zend_Session_Namespace('mobile');
		$mobile = $session -> mobile;
		$count_video = 0;
		if (isset($session -> count))
			$count_video = ++$session -> count;
		$paramsForCompile = array_merge(array(
			'video_id' => $this -> video_id,
			'code' => $this -> code,
			'view' => $view,
			'mobile' => $mobile,
			'duration' => $this -> duration,
			'count_video' => $count_video
		), $params);
		if ($this -> type == Ynvideo_Plugin_Factory::getUploadedType())
		{
			$responsive_mobile = FALSE;
			if (defined('YNRESPONSIVE'))
			{
				$responsive_mobile = Engine_Api::_() -> ynresponsive1() -> isMobile();
			}
			if (!empty($this -> file1_id))
			{
				$storage_file = Engine_Api::_() -> getItem('storage_file', $this -> file_id);
				if ($session -> mobile || $responsive_mobile)
				{
					$storage_file = Engine_Api::_() -> getItem('storage_file', $this -> file1_id);
				}
				if ($storage_file)
				{
					$paramsForCompile['location1'] = $storage_file -> getHref();
					$paramsForCompile['location'] = '';
				}
			}
			else 
			{
				$storage_file = Engine_Api::_() -> getItem('storage_file', $this -> file_id);
				if ($storage_file)
				{
					$paramsForCompile['location'] = $storage_file -> getHref();
					$paramsForCompile['location1'] = '';
				}
			}
		}
		else
		if ($this -> type == Ynvideo_Plugin_Factory::getVideoURLType())
		{
			$paramsForCompile['location'] = $this -> code;
		}
        $videoEmbedded = Ynvideo_Plugin_Factory::getPlugin((int)$this -> type) -> compileVideo($paramsForCompile);

		// $view == false means that this rich content is requested from the activity feed
		if ($view == false)
		{
			$video_duration = "";
			if ($this -> duration)
			{
				if ($this -> duration >= 3600)
				{
					$duration = gmdate("H:i:s", $this -> duration);
				}
				else
				{
					$duration = gmdate("i:s", $this -> duration);
				}
				$video_duration = "<span class='video_length'>" . $duration . "</span>";
			}

			// prepare the thumbnail
			$thumb = Zend_Registry::get('Zend_View') -> itemPhoto($this, 'thumb.large');
			if ($this -> photo_id)
			{
				$thumb = Zend_Registry::get('Zend_View') -> itemPhoto($this, 'thumb.large');
			}
			else
			{
				$thumb = '<img alt="" src="' . Zend_Registry::get('StaticBaseUrl') . 'application/modules/Video/externals/images/video.png">';
			}

			if (!$mobile)
			{
				$thumb = '<a id="video_thumb_' . $this -> video_id . $count_video . '" style="" href="javascript:void(0);" onclick="javascript:var myElement = $(this);myElement.style.display=\'none\';var next = myElement.getNext(); next.style.display=\'block\';">
                  <div class="video_thumb_wrapper">' . $video_duration . $thumb . '</div>
                  </a>';
			}
			else
			{
				$thumb = '<a id="video_thumb_' . $this -> video_id . $count_video . '" class="video_thumb" href="javascript:void(0);">
                  <div class="video_thumb_wrapper">' . $video_duration . $thumb . '</div>
                  </a>';
			}

			// prepare title and description
			$title = "<a class='smoothbox' href='" . $this -> getPopupHref($params) . "'>". $this-> getTitle()."</a>";
			$tmpBody = strip_tags($this -> description);
			$description = "<div class='video_desc'>" . (Engine_String::strlen($tmpBody) > 255 ? Engine_String::substr($tmpBody, 0, 255) . '...' : $tmpBody) . "</div>";

			$class_html5 = "";
			if ($this -> type == Ynvideo_Plugin_Factory::getVideoURLType() || $this -> type == Ynvideo_Plugin_Factory::getUploadedType())
			{
				$class_html5 = 'html5_player';
			}
			$totalLike = Engine_Api::_() -> getDbtable('likes', 'yncomment') -> likes($this) -> getLikeCount();
          	$totalDislike = Engine_Api::_() -> getDbtable('dislikes', 'yncomment') -> getDislikeCount($this);
			
			$videoEmbedded = '<div class="video_info">' .$title . $description . '</div>'.$thumb . '<div id="video_object_' . $this -> video_id . '" class="video_object ' . $class_html5 . '">' . $videoEmbedded . '</div>';
			
			$view = Zend_Registry::get('Zend_View');  
			$videoEmbedded .= '<div class="tfvideo_statistics">
          	<span>'. $view->translate(array('%s like', '%s likes', $totalLike), $totalLike). '</span>
          	<span>'. $view->translate(array('%s dislike', '%s dislikes', $totalDislike), $totalDislike). '</span>
          	<span>'. $view->translate(array('%s comment', '%s comments', $this -> comment_count), $this -> comment_count).'</span>
      		</div>';
		}

		return $videoEmbedded;
	}
Пример #8
0
	protected function addAdditionalElements()
	{
		// Init video
		$this -> addElement('Select', 'type', array(
			'label' => 'Video Source',
			'multiOptions' => array('0' => ' '),
			'onchange' => "updateTextFields()",
		));

		$video_options = Ynvideo_Plugin_Factory::getAllSupportTypes();

		$user = Engine_Api::_() -> user() -> getViewer();
		//My Computer
		$allowed_upload = Engine_Api::_() -> authorization() -> getAdapter('levels') -> getAllowed('video', $user, 'upload');
		$ffmpeg_path = Engine_Api::_() -> getApi('settings', 'core') -> ynvideo_ffmpeg_path;
		if (!(!empty($ffmpeg_path) && $allowed_upload))
		{
			unset($video_options[Ynvideo_Plugin_Factory::getUploadedType()]);
		}
		$this -> type -> addMultiOptions($video_options);

		//ADD AUTH STUFF HERE
		// Init url
		$this -> addElement('Textarea', 'url', array(
			'label' => 'Video Link (URL)',
			'description' => 'Paste the web address of the video here.',
		));
		$this -> url -> getDecorator("Description") -> setOption("placement", "append");
        
		$this -> addElement('Hidden', 'code', array('order' => 1));
		$this -> addElement('Hidden', 'id', array('order' => 2));
		$this -> addElement('Hidden', 'ignore', array('order' => 3));

		$this -> addElement('Dummy', 'html5_upload', array(
			'decorators' => array( array(
					'ViewScript',
					array(
						'viewScript' => '_Html5Upload.tpl',
						'class' => 'form element',
					)
				)),
		));
	}