<?php # Include the PHP Media API Wrapper require 'bc-mapi.php'; # Instantiate the class, passing it our Brightcove API tokens $bc = new BCMAPI('CO6uYEeNyUGE22AEvZkMKniQorK2vmR2bhYMNKXiKeHa_fqtcv640A..', ''); # Set up Constants define("TIMESTART", mktime(00, 00, 01, 01, 01, 2012)); #Timestamp of Jan 01, 2012 00:00:01 # Set up variables $tNow = time(); #Time stamp as of UNIX Epoch $tPassed = $tNow - TIMESTART; // Change this playlist if you want a different playlist to be simulated // could also pass this in as a parameter in the AJAX request $liveList = $bc->find('find_playlist_by_id', '2520498283001'); $totalDuration = 0; $videoIDs = array(); // go through each video to find the total duration foreach ($liveList->videos as $item => $video) { $totalDuration = $totalDuration + round($video->length / 1000); array_push($videoIDs, $video->id); } // find our location $plsection = $tPassed % $totalDuration; $totalDuration = 0; $currentvideo; $videoremainder; foreach ($liveList->videos as $item => $video) { $totalDuration = $totalDuration + round($video->length / 1000); if ($totalDuration > $plsection) {
/** * The constructor for the BCMAPIException class * @access Public * @since 1.0.0 * @param object [$obj] A pointer to the BCMAPI class * @param int [$error_code] The error code * @param string [$raw_error] Any additional error information */ public function __construct(BCMAPI $obj, $error_code, $raw_error = NULL) { $error = $obj->getErrorAsString($error_code); if (isset($raw_error)) { if (isset($raw_error->error) && isset($raw_error->error->message) && isset($raw_error->error->code)) { $raw_error = $raw_error->error; } $error .= "'\n"; $error .= isset($raw_error->message) && isset($raw_error->code) ? '== ' . $raw_error->message . ' (' . $raw_error->code . ') ==' . "\n" : ''; $error .= isset($raw_error->errors[0]) ? '== ' . $raw_error->errors[0]->error . ' (' . $raw_error->errors[0]->code . ') ==' . "\n" : ''; } parent::__construct($error, $error_code); }
<?php // This code example uses the PHP Media API wrapper // For the PHP Media API wrapper, visit opensource.brightcove.com // Include the BCMAPI SDK require 'bc-mapi.php'; // Instantiate the class, passing it our Brightcove API tokens (read, then write) $bc = new BCMAPI('jskS1rEtQHy9exQKoc14IcMq8v5x2gCP6yaB7d0hraRtO__6HUuxMg..', 'uikR5D2s7F-ODnXFRV6u7riQIDiHtsDNXRWsLS_mHltMKRMWr6mmYg..'); // Create an array of meta data from our form fields $metaData = array('name' => $_POST['bcVideoName'], 'shortDescription' => $_POST['bcShortDescription']); // Move the file out of 'tmp', or rename rename($_FILES['videoFile']['tmp_name'], '/tmp/' . $_FILES['videoFile']['name']); $file = '/tmp/' . $_FILES['videoFile']['name']; // Create a try/catch try { // Upload the video and save the video ID $id = $bc->createMedia('video', $file, $metaData); echo 'New video id: '; echo $id; } catch (Exception $error) { // Handle our error echo $error; die; }
<?php # Include & Instantiate require 'bc-mapi.php'; $bc = new BCMAPI('jskS1rEtQHy9exQKoc14IcMq8v5x2gCP6yaB7d0hraRtO__6HUuxMg..', 'uikR5D2s7F-ODnXFRV6u7riQIDiHtsDNXRWsLS_mHltMKRMWr6mmYg..'); # Only return ID and Tags data $params = array('video_fields' => 'id,tags'); # Request all videos from API $videos = $bc->findAll('video', $params); # Loop through videos foreach ($videos as $video) { # Assign tags to temporary variable $new_tags = $video->tags; # Add new tag $new_tags[] = 'newTag'; # Create new meta data $new_meta = array('id' => $video->id, 'tags' => $new_tags); # Send changes to API $bc->update('video', $new_meta); }
<?php require_once '../../scripts/bc-mapi.php'; /* https://github.com/BrightcoveOS/PHP-MAPI-Wrapper On a production site use the cache extension */ $read_token = "4padFp2KtFo3R8px9Gy8ugjQ1Pedl6fqsdp71_6Z9b6YOmzse5_G5g.."; $playlist_id = "1492396528001"; $bc_api = new BCMAPI($read_token, ''); $params = array('video_fields' => 'id,name,shortDescription,videoStillURL', 'playlist_id' => $playlist_id); try { $playlist = $bc_api->find('playlistbyid', $params); } catch (Exception $error) { echo $error; die; } ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Playlist</title> <style type="text/css"> .playlist-item { float: left; width: 400px; height:90px; background-color: #EEE; font-size: 80%; padding: 5px; margin: 2px; }
<!-- Brightcove URL: http://files.brightcove.com/bcl_facebook-opengraph-sample.php --> <style type="text/css"> body { background-color:#66CCCC; margin-top: 100px; margin-left: 100px; text-align:middle; } </style> <?php # Include the PHP SDK -- remember to make sure the include fits your directory structure, more abou the SDK can be found at http://opensource.brightcove.com/project/PHP-MAPI-Wrapper/ require 'bc-mapi.php'; # Instantiate the class, passing it our Brightcove API tokens $bc = new BCMAPI('jskS1rEtQHy9exQKoc14IcMq8v5x2gCP6yaB7d0hraRtO__6HUuxMg..', 'uikR5D2s7F-ODnXFRV6u7riQIDiHtsDNXRWsLS_mHltMKRMWr6mmYg..'); # Define our parameters //enter your publisher id $pubid = 57838016001.0; //enter the player id you would like to publish to facebook $fbplayid = 1463030067001.0; $fbplaykey = "AQ~~,AAAADXdqFgE~,aEKmio9UXag7mI6RpcOQDPGA271tZKoC"; //enter true false for if you want video to autoplay or not when thumbnail clicked in FB $fbautoplay = "true"; //enter the player id and player key you would like to publish on this page $playid = 1463030068001.0; $playkey = "AQ~~,AAAADXdqFgE~,aEKmio9UXaj62LQZfWSovLDmHDDA8rXn"; //set the page URL you want - you can use the curPageURL function to set to the current page. $pageulr = curPageURL(); //default video to load $vidid = 734462565001.0;
// Your read API token (with URL access) $bc_showHTTP = true; // Include http link for iOS $bc_validHTML5 = false; // Make code "valid" HTML5 (hide Open Graph metadata) // END OF OPTIONS // Uses opensource media api wrapper from http://opensource.brightcove.com/project/PHP-MAPI-Wrapper/ require 'bc-mapi.php'; // You may optionally include the caching extension provided with BCMAPI... // require('bc-mapi-cache.php'); // Using flat files // $bc_cache = new BCMAPICache('file', 600, '/var/www/myWebSite/cache/', '.cache'); // Using Memcached // $bc_cache = new BCMAPICache('memcached', 600, 'localhost', NULL, 11211); // Initialise $bc = new BCMAPI($bc_readToken, 'noWriteTokenNeeded'); if ($bc_KKaccount == true) { $bc->__set('url_read', 'api.brightcove.co.jp/services/library?'); $bc->__set('url_write', 'api.brightcove.co.jp/services/post'); $bc_serviceDomain = "brightcove.co.jp"; } else { $bc_serviceDomain = "brightcove.com"; } // Replace video id from url parameters if bctid is present. if (isset($_GET['bctid'])) { $bc_videoID = $_GET['bctid']; } // Set up params $bc->__set('media_delivery', 'http'); $bc_params = array('video_id' => $bc_videoID, 'video_fields' => 'name,shortDescription,videoStillURL,FLVURL'); // Make call