You are here

media_soundcloud.module in Media: SoundCloud 7.2

Same filename and directory in other branches
  1. 6 media_soundcloud.module
  2. 7 media_soundcloud.module

Provides a stream wrapper and formatters appropriate for accessing and displaying SoundCloud audio.

File

media_soundcloud.module
View source
<?php

/**
 * @file
 * Provides a stream wrapper and formatters appropriate for accessing and
 * displaying SoundCloud audio.
 */

// Load all SoundCloud file formatters.
require_once dirname(__FILE__) . '/includes/media_soundcloud.formatters.inc';

/**
 * Implements hook_media_internet_providers().
 */
function media_soundcloud_media_internet_providers() {
  return array(
    'MediaInternetSoundCloudHandler' => array(
      'title' => t('SoundCloud'),
    ),
  );
}

/**
 * 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_audio' => array(
      'variables' => array(
        'uri' => NULL,
        'options' => array(),
      ),
      'file' => 'media_soundcloud.theme.inc',
      'path' => $path . '/themes',
      'template' => 'media-soundcloud-audio',
    ),
  );
}

/**
 * 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_file_mimetype_mapping_alter().
 */
function media_soundcloud_file_mimetype_mapping_alter(&$mapping) {
  $mapping['mimetypes'][] = 'audio/soundcloud';
}

/**
 * Implements hook_ctools_plugin_api().
 */
function media_soundcloud_ctools_plugin_api($module, $api) {
  if ($module == 'file_entity' && $api == 'file_default_displays') {
    return array(
      'version' => 1,
    );
  }
}