i'd like to add an input filter that takes tags like [audio:123] to link to a node or [audio:http://example.com/foo.mp3] to link to a remote file and creates a flash player link.

i've run into a couple of problems:
- linking to audio nodes requires the audio module. not really a big deal but the remote stuff might be better if it didn't require the audio module.
- we know nothing about the remote files, they might not be compatible formats or bit rates.
- the flash players require that the files exist and be configured to point to a url. this sort of duplicates some of the audio module's functionality.

i'm kind of thinking the filter should be part of an audio_player module... the player module could allow the user to select the flash player... thoughts?

Comments

zirafa’s picture

"- linking to audio nodes requires the audio module. not really a big deal but the remote stuff might be better if it didn't require the audio module. "

The filter could just output nothing if the audio module is not installed and the user types in something like [audio:123].

"- we know nothing about the remote files, they might not be compatible formats or bit rates."
Check the extension to see if it's compatible with the flash player. If it's not compatible, just provide a link with a little download link music icon. If it is compatible, embed the flash player next to the icon. If the user realizes the flash player doesn't work with the file, provide an option to suppress the flash player: [audio:no-player:http://file.mp3] or something like that. Or vice versa, have an option to show the player but don't show it by default. Just have the music icon download link always though since that won't fail.

"- the flash players require that the files exist and be configured to point to a url. this sort of duplicates some of the audio module's functionality."
Not sure I understand this.

"i'm kind of thinking the filter should be part of an audio_player module... the player module could allow the user to select the flash player... thoughts?"

Maybe audio_inline.module would make more sense for a name? What do you envision the audio_player module doing by itself without a flash player? Maybe I don't fully understand the vision for this filter.

sun’s picture

IMHO, this should be handled by inline module. Inline already provides file mime type icons (with a patch). There are already thoughts to let inline.module work with other nodes by creating a inline API.

drewish’s picture

inline would be a good place to do it. i'd like to see that plugin api/hook to do so.

solipsist’s picture

+1 to this idea!

Has any work been done? I have a client who needs this feature. I am prepared to develop it and contribute it back unless someone is already working on it.

drewish’s picture

solipsist, i haven't done anything other than what's attached. feel free to update it. if it looks useful we can add it to contrib.

solipsist’s picture

Thanks for sharing! I'm gonna look at it!

drewish’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev

marked http://drupal.org/node/120182 as a duplicate of this.

yngens’s picture

Hi All,

I achieve this task by putting a code of a player, but this way you can only play local audio files, not remote ones. Anyway, let me repeat my question in http://drupal.org/node/120182:

Users of my website sometimes devote songs from audio archive of the website to each other, for instance when congratulating each other with birthdays. To do that they have to copy the following code by changing nid with id of the audio-file node.

<object height="17" width="17" type="application/x-shockwave-flash" data="/modules/audio/players/mp3.swf?song_url=/audio/play/nid"><param name="movie" value="/modules/audio/players/mp3.swf?song_url=/audio/play/nid"><param name="wmode" value="transparent"></object>

But it is not very convenient since only users with html access can do that. Is it possible to somehow put this code into some kind of filter and enable users to include in their posts any song from archive? For example, users could post something like [audio:nid] and filter automatically would put the code for the player? Or maybe there is other and easier way of including audio files to user postings?

yngens’s picture

i have audio module installed and when trying suggested audio_filter.module it gives the following error when linking to audio node:

Fatal error: Call to undefined function: audio_get_player() in /home/site/public_html/sites/all/modules/audio/contrib/filter/audio_filter.module on line 48

drewish’s picture

yeah that's some hella old code. i'm curious how sun's inline api has progressed. it might be a better framework to use for this now. i know he's a maintainer of the module now... maybe he'll chime in?

trond7’s picture

What is the status of making this as a working patch working for the Audio mudule?

Or, do anyone have another way of embedding audio from an audio node into another node?
(My context is making multimedia learning content. e.g. a student reading a text instructed assignment while listening to a audio file. )

It is possible to copy and passed the HTML from an audio node into another node (e.g. a book node), but the problem then is that does not support the feature of changing the media player on existing content due to that the URL to the player is hard coded.

joachim’s picture

In reply to #9: replace the call to the bad function with audio_get_node_player instead -- just change the function name, same parameters.

Also -- any news on inline.module working with audio module?

sun’s picture

Regarding Inline: The API is evolving and still in development, but there is still much to do. Image Assist will probably be the first module that will depend on it, beginning with 3.x series (hint: to get an idea about the envisioned timeframe: 2.x will be released soon).

joachim’s picture

In other words, it would be good for users if we included this handy little module in a new release of audio module so they've got this functionality right now :)

I've tested it with the change detailed in comment #12 and it works fine.

kade.’s picture

Greetings,

in which section we will upload this code that has been prepared? and what should we do to make this code work?

joachim’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new2.46 KB

Here's a zipfile of the complete module, with the change described in comment #12.
Tested and ready to go :)

drewish’s picture

Status: Reviewed & tested by the community » Needs work

this needs to be updated to 6.x first, i'm not going to commit any 5.x only features.

drewish’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
sagannotcarl’s picture

I'm a little confused about the code in #16. What exactly is var_dump($url); supposed to do here? It just printed the url to the screen for me.

I just changed the code to the following for now. I know it's probably a hack but I'm not sure how to pass the url to the module to build the player.

This is working fine for me but I'd rather it be cleaner.

function audio_filter_url_callback($matches) {
  $url = $matches[1];
  // var_dump($url);
  
  $output = '<object type="application/x-shockwave-flash" data="/sites/all/modules/audio/players/1pixelout.swf" width="290" height="24" >
    <param name="movie" value="/sites/all/modules/audio/players/1pixelout.swf" />
    <param name="wmode" value="transparent" />
    <param name="menu" value="false" />
    <param name="quality" value="high" />
    <param name="FlashVars" value="soundFile=' . $base_url . $url . '" />
    <embed src="/sites/all/modules/audio/players/1pixelout.swf" flashvars="soundFile=' . $base_url . $url . '" width="290" height="24" />
  </object>';
  
  return $output;
}
mrfelton’s picture

Still no Drupal 6 version of this module yet? If not, I may port the above code myself...

zengenuity’s picture

StatusFileSize
new1.8 KB

This version works and is compatible with Drupal 6.

Note: I made a few changes to suit my purposes, so feel free to change these to your liking.

  1. I changed the format from [audio: NID] to [audio: node:NID]. I did this because I have a video filter for use with FlashVideo that works this way, and I'm trying to keep it consistent for my users. You will likely want to change that back.
  2. I added an option in case the user wants to display the metadata that normally accompanies the audio player. If you use something like [audio: node:NID info:TRUE], then the metadata will show up.
  3. I changed the no cache option to false. I don't know why we shouldn't cache this.