예제 #1
0
/**
 * 
 * Delete a still thats associated with a video
 * 
 */
function s3_video_remove_video_still()
{
    if (!empty($_POST) && !empty($_POST['image_name']) && !empty($_POST['video_name'])) {
        $pluginSettings = s3_video_check_plugin_settings();
        require_once WP_PLUGIN_DIR . '/s3-video/includes/video_management.php';
        $videoManagement = new s3_video_management();
        $videoManagement->deleteVideoStill($_POST['video_name']);
        $s3Access = new S3($pluginSettings['amazon_access_key'], $pluginSettings['amazon_secret_access_key'], NULL, $pluginSettings['amazon_url']);
        $result = $s3Access->deleteObject($pluginSettings['amazon_video_bucket'], $_POST['image_name']);
    }
    die;
}
예제 #2
0
function s3_video_embed_video($embedDetails)
{
    $pluginSettings = s3_video_check_plugin_settings();
    if ($embedDetails['file']) {
        $videoFile = 'http://' . $pluginSettings['amazon_video_bucket'] . '.' . $pluginSettings['amazon_url'] . '/' . $embedDetails['file'];
    } else {
        return;
    }
    // See if the video has an associated still image
    require_once WP_PLUGIN_DIR . '/s3-video/includes/video_management.php';
    $videoManagement = new s3_video_management();
    $videoStill = $videoManagement->getVideoStillByVideoName($embedDetails['file']);
    if (!empty($videoStill)) {
        $videoStill = 'http://' . $pluginSettings['amazon_video_bucket'] . '.' . $pluginSettings['amazon_url'] . '/' . $videoStill;
    }
    if (!empty($videoFile)) {
        // Set up the flowplayer for video playback
        if (empty($pluginSettings['amazon_s3_video_player']) || $pluginSettings['amazon_s3_video_player'] == 'flowplayer') {
            $playerContent = s3_video_configure_player($embedDetails);
            $playerContent = str_replace('{videoFile}', $videoFile, $playerContent);
            // Define the playlist to support a video still
            $playlistHtml = 'playlist: [' . "\r\n";
            if (!empty($videoStill)) {
                $playlistHtml .= '{
            				url: "' . $videoStill . '", 
            				scaling: "fit",
            				autoPlay: true
        				},' . "\r\n";
            } else {
                if ($pluginSettings['amazon_s3_video_autoplay'] == 0) {
                    $playerContent = str_replace('{videoAutoPlay}', 'false', $playerContent);
                } else {
                    $playerContent = str_replace('{videoAutoPlay}', 'true', $playerContent);
                }
            }
            if (!empty($videoStill) && $pluginSettings['amazon_s3_video_autoplay'] == 0) {
                $playlistHtml .= '{
								url: "' . $videoFile . '",
								title: "' . $videoFile . '",
								autoPlay: false
							}' . "\r\n";
            } else {
                $playlistHtml .= '{
								url: "' . $videoFile . '",
								title: "' . $videoFile . '"
        					}' . "\r\n";
            }
            $playerContent = str_replace('{videoPlaylist}', $playlistHtml . ']', $playerContent);
            return $playerContent;
        } else {
            // prepare a videoJS player for video playback
            $playerContent = file_get_contents(WP_PLUGIN_DIR . '/s3-video/views/video-management/play_videoJS.php');
            $swfFile = WP_PLUGIN_URL . '/s3-video/misc/video-js.swf';
            $playerContent = str_replace('{swfFile}', $swfFile, $playerContent);
            $playerContent = str_replace('{playerId}', s3_plugin_player_id(), $playerContent);
            // Set the player dimensions
            if (!empty($embedDetails['width']) && $embedDetails['height']) {
                $playerContent = str_replace('{videoWidth}', $embedDetails['width'], $playerContent);
                $playerContent = str_replace('{videoHeight}', $embedDetails['height'], $playerContent);
            } else {
                $playerContent = str_replace('{videoWidth}', $pluginSettings['amazon_s3_video_playerwidth'], $playerContent);
                $playerContent = str_replace('{videoHeight}', $pluginSettings['amazon_s3_video_playerheight'], $playerContent);
            }
            // Define the buffering settings
            if ($pluginSettings['amazon_s3_video_autobuffer'] == 0) {
                $playerContent = str_replace('{videoBuffer}', 'none', $playerContent);
            } else {
                $playerContent = str_replace('{videoBuffer}', 'auto', $playerContent);
            }
            if ($pluginSettings['amazon_s3_video_autoplay'] == 0) {
                $playerContent = str_replace('{videoAutoPlay}', '', $playerContent);
            } else {
                $playerContent = str_replace('{videoAutoPlay}', 'autoplay="true"', $playerContent);
            }
            if (!empty($videoStill)) {
                $playerContent = str_replace('{videoStill}', 'poster="' . $videoStill . '"', $playerContent);
            } else {
                $playerContent = str_replace('{videoStill}', '', $playerContent);
            }
            $fileType = substr($videoFile, -3);
            if ($fileType == 'flv') {
                $videoTag = '<source src="' . $videoFile . '" type="video/x-flv">';
            } else {
                $videoTag = '<source src="' . $videoFile . '" type="video/mp4">';
            }
            $playerContent = str_replace('{videoFile}', $videoTag, $playerContent);
            return $playerContent;
        }
    }
}