Not really a feature request, but I didn't know what category to select :)

For my site I implemented a couple of 'codecs' for music sharing websites: SoundClick, ReverbNation, SoundCloud and Bandcamp. I also implemented a codec for recorded videos on Ustream.tv (doesn't work for streams). Finally I also made one that plays any random MP3 file through the flash player provided by the 'MP3 player' module that's also installed on the site.

I'm just gonna post these here in case someone else finds them useful. The implementations are rather half-assed though (hardcoded width/height for example), I just wanted to get it to work, really. I don't know if there are plans to extend video filter's support to non-video services, but at any rate I found the module very useful for this purpose. Maybe my code is useful as a starting point for other people as well.

I also changed the syntax from [video:URL] to [media]URL[/media], it fits the rest of the site better (BBCode is used everywhere) and 'media' makes more sense than 'video' of audio embeds are also supported. It would be very cool if I could make such a change through the administration interface at some point in the future, instead of having to hack it in :)

I threw the code on pastebin because putting all of it inside this post didn't seem to work. And it would maybe clutter things up a bit as well.

Here it is: http://pastebin.com/zRkwNr2j

Thanks for this awesome module :)

Comments

blackdog’s picture

Status: Active » Postponed

This is good stuff. I'm not sure what to do with it though... This is a _video_ filter module by definition, but this kind of support wouldn't be hard to add. It would need a new tag (video: doesn't sound right) and perhaps other settings.

On the other hand, emfield can handle other media types out of the box, and for Drupal 7, the Media module. Might be duplicated efforts to add other media support in this module (or a new one, like Media Filter)?

Great work though!

benanne’s picture

Well, I tried to use emfield's "eminline" submodule first to achieve what I wanted. However, I soon found out that eminline only supports video embedding, even though emfield also has support for audio services. That made it useless for what I wanted to achieve.

First I considered extending eminline to also support audio services, but that seemed very challenging (I'm a newbie when it comes to Drupal module development), and something else I didn't like about eminline was that it extracts all URLs, i.e. not just the ones wrapped in some tag. That makes it impossible to link media instead of embedding.

The Video Filter module turned out to be a perfect fit, because of its easy extensibility. I whipped up most of the code in an evening.

I'm not arguing that you should include my code in the module (in fact I would argue against it, as it's way too half-assed for that), but I thought I would share it nevertheless in case someone else wants to achieve something similar. I think renaming 'Video Filter' to 'Media Filter' at some point wouldn't be a bad idea though ;)

I agree that duplicate work should be avoided, but it seems that eminline is mostly neglected by the emfield developers. So I was happy to find that this module exists :) I haven't looked into Drupal 7's Media module yet as I'm sticking with Drupal 6 for the time being.

hedac’s picture

Thank you very much !
I was going to do the same.. but I thought... let's check on the issues list first... I also use this module to embed audio because I think it's good. Not planning to upgrade to drupal 7 and the media module yet because I think it's not yet ready.

hedac’s picture

The bandcamp module is not working for me...

updated the soundclick codec

$codecs['soundclick'] = array(
    'name' => t('SoundClick'),
    'sample_url' => 'http://soundclick.com/share.cfm?id=123456789',
    'callback' => 'video_filter_soundclick',
    'regexp' => '@soundclick\.com/share\.cfm\?id=([^\&]+)@i',
    'ratio' => 473 / 60,
  );
function video_filter_soundclick($video) {
  // inspired by the SoundClick provider for emfield 5.x (it was discontinued in 6.x)
  //$band_id = $video['codec']['matches'][1];
  $song_id = $video['codec']['matches'][1];
  $output = '
  <object type="application/x-shockwave-flash" allowScriptAccess="never" allowNetworking="internal" height="60" width="473" data="http://www.soundclick.com/player/V2/mp3player.swf">
  <param name="allowScriptAccess" value="never" />
  <param name="allowNetworking" value="internal" />
  <param name="movie" value="http://www.soundclick.com/player/V2/mp3player.swf" />
  <param name="loop" value="false" />
  <param name="menu" value="false" />
  <param name="quality" value="high" />
  <param name="wmode" value="transparent" />
  <param name="flashvars" value="playType=single&songid='.$song_id.'&scid='.$song_id.'&q=hi&ext=1&autoplay=0" />
  <param name="scale" value="noscale" />
  <param name="salign" value="b" />
  <param name="bgcolor" value="#000000" />
</object>
';
  return $output;
}
benanne’s picture

Yeah, Bandcamp changed their HTML at some point. Here's the code I'm currently using. Should work for albums as well as individual tracks :)

  $codecs['bandcamp'] = array(
    'name' => t('Bandcamp'),
    'sample_url' => 'http://bandname.bandcamp.com/track/trackname',
    'callback' => 'video_filter_bandcamp',
    'regexp' => '@((?:\w+)\.bandcamp\.com/(?:[^"\&]*))@i',
    'ratio' => 400 / 100,
  );


function video_filter_bandcamp($video) {
  // based on the 'Media: Bandcamp' module: http://drupal.org/project/media-bandcamp
 
  $response = drupal_http_request("http://" . $video['codec']['matches']['0']);
  if ($response->code == 200) {
    //extract 'album' or 'track' and unique numerical identifier
    // preg_match('@(?:video_src.+)(album|track)=([\d]+)@i', $response->data, &$matches); // old way, doesn't work anymore
    // match against: tralbum_param : { name : "album", value : 3782954029 },
    preg_match('@tralbum_param : { name : "(album|track)", value : ([\d]+) }@i', $response->data, &$matches);

    $type = $matches[1]; // 'album' or 'track'
    $code = $matches[2]; // the numerical identifier for the album or track
  }
  
  $width = 400;
  $height = 100;
  
  
  $output = <<<BC
<object data="http://bandcamp.com/EmbeddedPlayer/{$type}={$code}/size=venti/bgcol=E4E4E4/linkcol=B81C14//"
type="text/html" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{$width}" height="{$height}">
<param name="movie" value="http://bandcamp.com/EmbeddedPlayer/{$type}={$code}/size=venti/bgcol=E4E4E4/linkcol=B81C14//">
<param name="quality" value="high">
<param name="allowNetworking" value="always">
<param name="wmode" value="transparent">
<param name="bgcolor" value="#E4E4E4">
<param name="allowScriptAccess" value="never">
<object data="http://bandcamp.com/EmbeddedPlayer/{$type}={$code}/size=venti/bgcol=E4E4E4/linkcol=B81C14//" type="text/html" width="{$width}" height="{$height}">
</object></object>
BC;

  return $output;
}


minnur’s picture

Status: Postponed » Closed (outdated)

Closing this issue. For D7 there is https://www.drupal.org/project/audio_filter