1

I want to create a field as a link. I want this link to be displayed as a custom embedded player.

I have checked out How do I add embedded YouTube videos in a field? and the Embedded Media Field module however this solution does not work for me.

  1. I do not like the admin interface/configuration.
  2. The module does not support my flash player.

Any suggestion would be great.

2

Another method is to create you own module. Checkout Media Link

Below is the code you would need. This module adds a podbean audio player display for your link field. Modify the theme code for your embedded player. Another good place to look at is the field example module.

Again, this module requires the Link module

<?php

/**
 * @file
 * Defines a display format for a link that will embed a player.
 */

/**
 * Implements hook_field_formatter_info().
 */
function media_link_field_formatter_info() {
  return array(
    'audio_player' => array(
      'label' => t('Audio Player'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
      'field types' => array('link_field'),
    ),
    /*
    'video_player' => array(
      'label' => t('Video Player'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
      'field types' => array('link_field'),
    ),
    */
  );
}


/**
 * Implements hook_field_formatter_view().
 */
function media_link_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $elements = array();
  foreach ($items as $delta => $item) {
    $elements[$delta] = array(
      '#markup' => theme('link_formatter_'. $display['type'], array('element' => $item, 'field' => $instance)),
    );
  }
  return $elements;
}

/**
 * Implements hook_theme().
 */
function media_link_theme() {
  return array(
      'link_formatter_audio_player' => array(
          'variables' => array('element' => NULL),
    ),
  );
}

/**
 * Theme function for 'audio player' link field formatter.
 */
function theme_link_formatter_audio_player($vars) {

  $url = $vars['element']['url'];
  return "<div>" .
  "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='210' height='25' id='mp3playerlightsmallv3' align='middle'>" .
  "<param name='allowScriptAccess' value='sameDomain' />" .
  "<param name='movie' value='http://www.podbean.com/podcast-audio-video-blog-player/mp3playerlightsmallv3.swf?audioPath=" . $url . "&autoStart=no' />" .
  "<param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><param name='wmode' value='transparent' />" .
  "<embed src='http://www.podbean.com/podcast-audio-video-blog-player/mp3playerlightsmallv3.swf?audioPath=" . $url . "&autoStart=no' quality='high'  width='210' height='25' name='mp3playerlightsmallv3' align='middle' allowScriptAccess='sameDomain' wmode='transparent' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></embed>" .
  "</object>" .
  "</div>";
}

?>
0

Checkout Drupal Tutorial - Creating an embedded video or audio player for a link field

Dependency Modules:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.