The concept of this module is to let it handle content that is coming from an (undefined) creator and turn it in to something meaningful. To test this concept we need to hack some existing modules to prove it works.

E.g.

  • Can we get audio from the audio.module to appear in a player that is defined in embed, or is interfacing with embed?
  • Can we get a module that currently embeds flash directly / via its own library, to embed it generically via embed? E.g. emfield when it places Google video on a page?

Comments

Stuart Greenfield’s picture

I think this is fairly straightforward. It needs more testing but I have audio module outputting in to the embed module, so we can embed content straight on the page, or in FlowPlayer.

All that was necessary was to register embed as an audio player with the audio module, register the theme, and inside the theme build an audio object.

So

// Register our module
function embed_audio_audio_player() {
  $items['embed_audio'] = array(
    'module'      => 'embed_audio',
    'title'       => t('Embed interface'),
    'description' => t('Allows the audio module to interface with embed.'),
    'url'         => t('http://drupal.org/project/embed'),
    //'preview'     => 'players/1pixelout.png',
    'formats'     => array('wav', 'mp3'),
    'theme_node'  => 'embed_audio_node_player',
  );
  return $items;
}

// Register the theme
function embed_audio_theme() {
  
  return array(
    'embed_audio_node_player' => array(
      'arguments' => array('node'),
    ),
  
  );

}


// Implement embed module
function theme_embed_audio_node_player($node, $options = array()) {
  
  $object = array(
    'type' => $node->audio['file']->filemime,
    'data' => $node->url_download,
  );
  
  $element = array(
    '#type' => 'object',
    '#attributes' => $object,
  );
  
  return drupal_render($element);
}

This seems to suggest that we have a viable model here - audio.module knows nothing about FlowPlayer, but it can now use it. Instead of someone having to write an audio specific version of FlowPlayer we can access a generic FlowPlayer module. And the audio module now doesn't have to implement flash embedding (out of interest, it uses direct embedding).

As a minimum it would seem feasible that modules could at least offer the option to support the embed interface.

Some more testing is needed. In particular FlowPlayer doesn't seem to like urls of the form audio/play/nn - it says it can't find the stream. Direct embedding works ok so this might be a FlowPlayer glitch. For now we can use url_download instead.

Stuart Greenfield’s picture

OK - the FlowPlayer issue is that it tries to determine the clip type from the extension of the file and audio/play/nn doesn't have an extension.

You can fix this by forcing the type using what appears to be an undocumented feature in FlowPlayer3 where you can set the clip type explicity, using 'type' => 'mp3'. There's a page for FlowPlayer2 at http://flowplayer.org/v2/player/playlists.html#filetypes.

I tried that locally and now it works.

This would affect anything that calls FlowPlayer - not just embed, so I think the embed_flowplayer module needs to see if there's an extension on the file, and if there isn't then try to guess the type.

For reference, inside ClipType.as

		public static function fromFileExtension(name:String):ClipType {
			var dotPos:Number = name.lastIndexOf(".");
			var lcName:String = name.toLowerCase();
			var extension:String = lcName.substring(dotPos + 1, lcName.length);
			return resolveType(extension);
		}
		
		public static function resolveType(type:String):ClipType {
			if (['3g2', '3gp', 'aac', 'f4b', 'f4p', 'f4v', 'flv', 'm4a', 'm4v', 'mov', 'mp4', 'vp6', 'mpeg4', 'video'].indexOf(type) >= 0)
				return ClipType.VIDEO;
			if (['png', 'jpg', 'jpeg', 'gif', 'swf', 'image'].indexOf(type) >= 0)
				return ClipType.IMAGE;
			if (type == 'mp3')
				return ClipType.AUDIO;
			
			return ClipType.VIDEO;
		}
Stuart Greenfield’s picture

Issue with FlowPlayer now fixed - added a function to check if the url has an extension, and if it doesn't then the type is set according to mime type. FlowPlayer is now working nicely with audio module.

I added an early version of 1PixelOut to embed tonight. This is already supported natively in audio.module, but with it assigned in embed module you can use the version via embed.

Again, this seems to suggest we're going in the right direction - this module might let us build a really good set of player modules and use these for all applications that need player support.

dave reid’s picture

Issue summary: View changes
Status: Active » Closed (fixed)