I'm writing a custom provider for emaudio that would allow icecast streams urls to be parsed into a player and the currently playing track.

In order to constantly update the current track, I've written some ajax to do so. However, I can't get it to work because the provider file isn't loaded when it needs to process hook_menu().

So, I need some help figuring out how best to alter emaudio to get this to work. We could have emaudio_menu() load the provider files and allow drupal to process their hook_menu(). But then how do you get it to load the provider file when the js function is requested?

I've attached the provider files in case you would like to review what I've done.

Help would be much appreciated!

Comments

moonray’s picture

Title: New custom icecast stream provider, can't use ajax » New custom icecast stream provider
Status: Active » Needs review
StatusFileSize
new13.32 KB

I found an elegant solution. See #345383.

Using that patch, here is the patch to add the update provider.

moonray’s picture

StatusFileSize
new13.32 KB

Update to the patch. The ajax wasn't updating the song beyond the first time. Now it is.

aaron’s picture

Status: Needs review » Needs work
StatusFileSize
new14.58 KB

First iteration looks good. I added an hook_update_N function to rebuild the menu to grab our new emfield/icecast/js.

However, I'm getting the following errors after applying when adding existing emaudio provider content:

    * warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "crossdomain.xml" in /home/aaronwin/domains/drupal-developer.org/public_html/sites/all/modules/emfield/contrib/emaudio/providers/icecast.inc on line 94.
    * Could not find a valid crossdomains.xml. Please create it (or fix it) and place it in the root of your drupal installation. Find more information about crossdomain.xml at adobe.com.
    * warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "crossdomain.xml" in /home/aaronwin/domains/drupal-developer.org/public_html/sites/all/modules/emfield/contrib/emaudio/providers/icecast.inc on line 94.

Additionally, as icecast is a non-standard item, it really needs documentation for editors and administrators as to how they would use it.

Thanks for the work so far!

moonray’s picture

Status: Needs work » Needs review
StatusFileSize
new17.43 KB

Added code to catch errors/exception.
Added documentation.

Attached new path. Please review and comment on any changes/additions needed.

alex ua’s picture

I'm having problems getting this to work. I applied the patch, added the crossdomain.xml and put 1.fm (which I found on the list of streams on icecast.org) into it, and then tried to add a stream.

First I received errors about unidentified indexes related to emaudio_icecast_form() since I didn't enter a username or password into the settings page. I changed that function to include the following, which got rid of the errors, but I'm not sure it worked:

 //If the user has entered their username and password in the module settings 
 //than it should be automatically entered, 
 //otherwise it can be entered on the emaudio submission form
 $username = '';
 $password = '';
 if (isset($item['data']['icecast']['username']) && isset($item['data']['icecast']['password'])){
    $username = $item['data']['icecast']['username'];
    $password = $item['data']['icecast']['password'];
  }

  $form['icecast']['username'] = array(
    '#type' => 'textfield',
    '#title' => t('Username'),
    '#default_value' => $username,
    '#size' => 32,
    '#maxlength' => 32,
  );
  $form['icecast']['password'] = array(
    '#type' => 'textfield',
    '#title' => t('Password'),
    '#default_value' => $password,
    '#size' => 32,
    '#maxlength' => 32,
  );

I'm not sure if this is the correct way to address this, but when i first tried to add an emaudio node the $item array was empty, so the idea was to check to see if it existed first before trying to pull info from the array. What do you think?

The second problem I'm getting is the following error after attempting to add an emaudio node:

    * warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 11 in C:\xampp\htdocs\drupal6\sites\all\modules\emfield\emfield.module on line 154.
    * You have specified an invalid media URL or embed code.

What url am I supposed to be embedding? I tried posting a bunch of urls, and all gave me this error.

Any ideas?

alex ua’s picture

Status: Needs review » Needs work
alex ua’s picture

Status: Needs work » Closed (fixed)

This never seems to have been completed. For the future it will need a media: Icecast module in order to work (see Media: Souncloud for an example on how to do this).