The machine name of the provider. This must be the same as * the base name of this filename, before the .inc extension. * 'name' => The translated name of the provider. * 'url' => The url to the main page for the provider. * 'settings_description' => A description of the provider that will be * posted in the admin settings form. * 'supported_features' => An array of rows describing the state of certain * supported features by the provider. These will be rendered in a table, * with the columns being 'Feature', 'Supported', 'Notes'. In general, * the 'Feature' column will give the name of the feature, 'Supported' * will be Yes or No, and 'Notes' will give an optional description or * caveats to the feature. */ function emvideo_archive_info() { $features = array( array(t('Autoplay'), t('Yes'), ''), array(t('RSS Attachment'), t('Yes'), ''), array(t('Thumbnails'), t('Yes'), t('')), array(t('Full screen mode'), t('Yes'), t('You may customize the player to enable or disable full screen playback. Full screen mode is enabled by default.')), ); return array( 'provider' => 'archive', 'name' => t('archive.org'), 'url' => EMVIDEO_ARCHIVE_MAIN_URL, 'settings_description' => t('These settings specifically affect videos displayed from !archive. You can also read more about its !api.', array('!archive' => l(t('Archive.com'), EMVIDEO_ARCHIVE_MAIN_URL), '!api' => l(t("developer's API"), EMVIDEO_ARCHIVE_API_URL))), 'supported_features' => $features, ); } /** * hook emvideo_PROVIDER_settings * This should return a subform to be added to the emvideo_settings() admin * settings page. * * Note that a form field set will already be provided at $form['archive'], * so if you want specific provider settings within that field set, you should * add the elements to that form array element. */ function emvideo_archive_settings() { // We'll add a field set of player options here. You may add other options // to this element, or remove the field set entirely if there are no // user-configurable options allowed by the archive provider. /* $form['archive']['player_options'] = array( '#type' => 'fieldset', '#title' => t('Embedded video player options'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); // This is an option to set the video to full screen. You should remove this // option if it is not provided by the archive provider. $form['archive']['player_options']['emvideo_archive_full_screen'] = array( '#type' => 'checkbox', '#title' => t('Allow fullscreen'), '#default_value' => variable_get('emvideo_archive_full_screen', 1), '#description' => t('Allow users to view video using the entire computer screen.'), ); return $form;*/ } /** * hook emvideo_PROVIDER_extract * * This is called to extract the video code from a pasted URL or embed code. * * We'll be passed a URL or the embed code from a video when an editor pastes * that in the field's textfield. We'll need to either pass back an array of * regex expressions to match, or do the matching ourselves and return the * resulting video code. * * @param $parse * An optional string with the pasted URL or embed code. * @return * Either an array of regex expressions to be tested, or a string with the * video code to be used. If the hook tests the code itself, it should * return either the string of the video code (if matched), or an empty * array. Otherwise, the calling function will handle testing the embed code * against each regex string in the returned array. */ function emvideo_archive_extract($parse = '') { // Here we assume that a URL will be passed in the form of // http://www.archive.org/video/text-video-title // or embed code in the form of $value) { $item_files[$key]['name'] = $key; } //Get only .mp4 files $files_play = array_filter($item_files, "_archive_video_toplay"); //If there is no playlist then fail if (is_null($files_play)) { form_set_error($error_field, 'This archive.org item does not appear to have files to play.'); return $data; } //Create a playlist suitable for feeding to player foreach ($files_play as $file => $file_data) { $data['playlist'][] = $download_url . $file; } // Add the thumbnail data. $data['thumbnail'] = 'http://www.archive.org/download/'. $item['value'] .'/format=Thumbnail?.jpg'; return $data; } /** * Is this a 512Kb MPEG4 file? */ function _archive_video_toplay($file) { if ($file['format'] == "512Kb MPEG4") { return TRUE; } else { return FALSE; } } /** * hook emvideo_PROVIDER_duration($item) * Returns the duration of the video in seconds. * @param $item * The video item itself, which needs the $data array. * @return * The duration of the video in seconds. */ function emvideo_archive_duration($item) { if (!isset($item['data']['emvideo_archive_version'])) { $item['data'] = emvideo_archive_data(NULL, $item); } return isset($item['data']['metadata']['RUNTIME'][0]) ? emvideo_convert_to_seconds($item['data']['metadata']['RUNTIME'][0]) : 0; } /** * hook emvideo_PROVIDER_rss * * This attaches a file to an RSS feed. */ function emvideo_archive_rss($item, $teaser = NULL) { if ($item['value']) { $file['thumbnail']['filepath'] = $item['data']['thumbnail']; return $file; } } /** * hook emvideo_PROVIDER_embedded_link($video_code) * returns a link to view the video at the provider's site. * @param $video_code * The string containing the video to watch. * @return * A string containing the URL to view the video at the original provider's site. */ function emvideo_archive_embedded_link($video_code) { return 'http://www.archive.org/details/'. $video_code; } /** * The embedded flash displaying the archive video. */ function theme_emvideo_archive_flash($item, $width, $height, $autoplay) { $output = ''; if ($item['embed']) { $flowplayerplaylist = _media_archive_flowplayer_playlist($item['data']['playlist']); $controlplaylist = (count($item['data']['playlist'])>1) ? "true" : "false"; $clipautoplay = $autoplay ? 'true' : 'false'; $output = << EOD; } return $output; } /** * hook emvideo_PROVIDER_thumbnail * Returns the external url for a thumbnail of a specific video. * @param $field * The field of the requesting node. * @param $item * The actual content of the field from the requesting node. * @return * A URL pointing to the thumbnail. */ function emvideo_archive_thumbnail($field, $item, $formatter, $node, $width, $height) { // In this demonstration, we previously retrieved a thumbnail using oEmbed // during the data hook. return $item['data']['thumbnail']; } /** * hook emvideo_PROVIDER_video * This actually displays the full/normal-sized video we want, usually on the * default page view. * @param $embed * The video code for the video to embed. * @param $width * The width to display the video. * @param $height * The height to display the video. * @param $field * The field info from the requesting node. * @param $item * The actual content from the field. * @return * The html of the embedded video. */ function emvideo_archive_video($embed, $width, $height, $field, $item, $node, $autoplay) { $output = theme('emvideo_archive_flash', $item, $width, $height, $autoplay); return $output; } /** * hook emvideo_PROVIDER_video * * This actually displays the preview-sized video we want, commonly for the * teaser. * @param $embed * The video code for the video to embed. * @param $width * The width to display the video. * @param $height * The height to display the video. * @param $field * The field info from the requesting node. * @param $item * The actual content from the field. * @return * The html of the embedded video. */ function emvideo_archive_preview($embed, $width, $height, $field, $item, $node, $autoplay) { $output = theme('emvideo_archive_flash', $item, $width, $height, $autoplay); return $output; } /** * Implementation of hook_emfield_subtheme(). * This returns any theme functions defined by this provider. */ function emvideo_archive_emfield_subtheme() { $themes = array( 'emvideo_archive_flash' => array( 'arguments' => array('item' => NULL, 'width' => NULL, 'height' => NULL, 'autoplay' => NULL), 'file' => 'providers/archive.inc', // If you don't provide a 'path' value, then it will default to // the emvideo.module path. Obviously, replace 'emarchive' with // the actual name of your custom module. //'path' => drupal_get_path('module', 'emarchive'), ) ); return $themes; } /** * Implement hook_emvideo_PROVIDER_content_generate(). */ function emvideo_archive_content_generate() { return array( 'http://www.archive.org/details/DrupalconDc2009-DrupalMultimedia', 'http://www.archive.org/details/DrupalconBoston2008-DrupalMultimedia', 'http://www.archive.org/details/drupal_song_dcamp_pune_09', 'http://www.archive.org/details/Drupal.Peru_DrupalSong20090718', ); }