コード例 #1
0
/**
 * Display a page for handling the meta data belonging to a video
 */
function s3_video_meta_data()
{
    $pluginSettings = s3_video_check_plugin_settings();
    $videoName = urldecode($_GET['video']);
    if (empty($videoName)) {
        die('Video not found..');
    }
    require_once WP_PLUGIN_DIR . '/s3-video/includes/video_management.php';
    $videoManagement = new s3_video_management();
    s3_video_check_user_access();
    $pluginSettings = s3_video_check_plugin_settings();
    $tmpDirectory = s3_video_check_upload_directory();
    if (!empty($_FILES) && $_FILES['upload_still']['size'] > 0) {
        $stillTypes = array('image/gif', 'image/png', 'image/jpeg');
        if (!in_array($_FILES['upload_still']['type'], $stillTypes) || $_FILES['upload_still']['error'] > 0) {
            $errorMsg = 'The uploaded file is not able to be used as a video still.';
        } else {
            $imageDimensions = getimagesize($_FILES['upload_still']['tmp_name']);
            if ($imageDimensions[0] < 200 || $imageDimensions[1] < 200 || $imageDimensions[0] > 3000 || $imageDimensions[1] > 3000) {
                $errorMsg = 'Your video still needs to be over 200px x 200px in size and under 3000px x 3000px';
            } else {
                $fileName = time() . '_' . basename($_FILES['upload_still']['name']);
                $fileName = preg_replace('/[^A-Za-z0-9_.]+/', '', $fileName);
                $imageLocation = $tmpDirectory . $fileName;
                if (move_uploaded_file($_FILES['upload_still']['tmp_name'], $imageLocation)) {
                    $s3Access = new S3($pluginSettings['amazon_access_key'], $pluginSettings['amazon_secret_access_key'], NULL, $pluginSettings['amazon_url']);
                    $s3Result = $s3Access->putObjectFile($imageLocation, $pluginSettings['amazon_video_bucket'], $fileName, S3::ACL_PUBLIC_READ);
                    switch ($s3Result) {
                        case 0:
                            $errorMsg = 'Request unsucessful check your S3 access credentials';
                            break;
                        case 1:
                            $successMsg = 'The image has successfully been uploaded to your S3 account';
                            // Save the image to the database
                            $videoManagement->deleteVideoStill($videoName);
                            $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']);
                            $videoManagement->createVideoStill($fileName, $videoName);
                            break;
                    }
                }
            }
        }
    }
    // Check and see if there is a still in the database for this video
    $videoStill = $videoManagement->getVideoStillByVideoName($videoName);
    $stillFile = '';
    if (!empty($videoStill)) {
        $stillFile = $videoStill;
        $videoStill = 'http://' . $pluginSettings['amazon_video_bucket'] . '.' . $pluginSettings['amazon_url'] . '/' . urlencode($videoStill);
    }
    require_once WP_PLUGIN_DIR . '/s3-video/views/video-management/meta_data.php';
}
コード例 #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;
        }
    }
}