array( 'title' => 'soundcloud', 'image' => $path . '/images/stream-soundcloud.png' ), ); } /** * Implements hook_stream_wrappers(). */ function media_soundcloud_stream_wrappers() { return array( 'soundcloud' => array( 'name' => t('SoundCloud audio'), 'class' => 'MediaSoundCloudStreamWrapper', 'description' => t('Audio provided by SoundCloud.'), 'type' => STREAM_WRAPPERS_READ_VISIBLE, ), ); } /** * Implements hook_theme(). */ function media_soundcloud_theme($existing, $type, $theme, $path) { return array( 'media_soundcloud_preview_style' => array( 'variables' => array('style_name' => NULL), 'file' => 'media_soundcloud.theme.inc', 'path' => $path . '/includes/themes', ), 'media_soundcloud_field_formatter_styles' => array( 'variables' => array('element' => NULL, 'style' => NULL), 'file' => 'media_soundcloud.theme.inc', 'path' => $path . '/includes/themes', ), 'media_soundcloud_audio' => array( 'variables' => array('uri' => NULL, 'width' => NULL, 'autoplay' => NULL, 'extra_params' => NULL), 'file' => 'media_soundcloud.theme.inc', 'path' => $path . '/includes/themes', 'template' => 'media-soundcloud-audio', ), 'media_soundcloud_embed' => array( 'variables' => array('style_name' => NULL, 'uri' => NULL, 'alt' => NULL, 'title' => NULL), 'file' => 'media_soundcloud.theme.inc', 'path' => $path . '/includes/themes', ), 'media_soundcloud_styles' => array( 'variables' => array('element' => NULL, 'style' => NULL), 'file' => 'media_soundcloud.theme.inc', 'path' => $path . '/includes/themes', ), ); } /** * Implements hook_media_parse(). * * @todo This hook should be deprecated. Refactor Media module to not call it * any more, since media_internet should be able to automatically route to the * appropriate handler. */ function media_soundcloud_media_parse($embed_code) { $handler = new MediaInternetSoundCloudHandler($embed_code); return $handler->parse($embed_code); } /** * Implements hook_media_format_form_prepare_alter(). */ function media_soundcloud_media_format_form_prepare_alter(&$form, &$form_state, $media) { $settings = array('autosubmit' => ($media->type == "audio")); drupal_add_js(array('media_format_form' => $settings), 'setting'); } /** * Implements hook_ctools_plugin_api(). */ function media_soundcloud_ctools_plugin_api($owner, $api) { static $api_versions = array( 'file_entity' => array( 'file_default_displays' => 1, ), ); if (isset($api_versions[$owner][$api])) { return array('version' => $api_versions[$owner][$api]); } } /** * Implements hook_file_mimetype_mapping_alter(). * * Create a fake mimetype so it will be compatible with File Entity's dev changes * which now requires each file type to select supported mime types */ function media_soundcloud_file_mimetype_mapping_alter(&$mapping) { $mapping['mimetypes'][] = 'audio/soundcloud'; } /* * Implements hook_file_default_types_alter(). * * Adds the audio/soundcloud fake mimetype to audio files. */ function media_soundcloud_file_default_types_alter(&$types) { $types['audio']->mimetypes[] = 'audio/soundcloud'; }