The guys over at the SoundManager2 module are working to add support for the soundmanager2 player in D7. I took the liberty (here: #1146172: Merge with audiofield module) of suggesting to them that they merge their efforts with you here. Do you have any time or interest in supporting other players?

If none of you are interested in merging the two modules, then I might be tempted to look at it. I took a look at the API for audiofield, and it almost looks too easy! :-) It looks like there are just two functions to implement in a module. I can write php, but, unfortunately, I really don't know javascript. Are those two functions all I need?

Thanks again for your work!

CommentFileSizeAuthor
#6 add_soundmanager2-1146268-6.patch4.89 KBgagarine
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tamerzg’s picture

Yes those 2 functions are all you need. Basically you just need to paste embedd code of Soundmanger in 2nd function and replace some arguments with php variables as in given example.

It would be best if the guys at Soundmanager add this to their module, implementing audiofield hooks. This way they could focus on Soundmanager UI, while the background work will be done by Audiofield.

BeaPower’s picture

Does it work now?

tamerzg’s picture

Don't think they implemented it yet. You can ask Soundmanager module maintainers at http://drupal.org/node/1146172

infines’s picture

The sound manager 2 module is pretty quiet... However I see in the repository viewer that SM2 functionality has been added to the 6.x version of audiofield, will it be coming to the d7 version too then?

tamerzg’s picture

Yes it will be ported to D7 in the coming days.

gagarine’s picture

Status: Active » Needs review
FileSize
4.89 KB

Voilà... a patch.

It can be better.. using theme function and so. But it works and should be pretty easy to improve.

I also added what I said in #1468796: Send the field to the players so we can display the file's title so I can display the file title.

gagarine’s picture

I also add $settings360 but no time for a patch right now...

function audiofield_soundmanager2($player_path, $audio_file,$variables) {
  static $instanceIndex = 0;
  if ($audio_file == '') {
    return t('HTML5 media player for soundmanager2 (skin 360-player)');
  }
  else {
    $instanceIndex += 1;
    if (!empty($variables['file']->description)) {
      $filename = $variables['file']->description;
    }
    else {
      $filename = $variables['file']->filename;
    }
    //Add JS files and settings only one time
    if ($instanceIndex == 1) {

      $player_base_path = variable_get('audiofield_players_dir', 'sites/all/libraries/player') . "/soundmanager2";
      $ie_js = array(
        '#type' => 'markup',
        '#markup' => '<!--[if IE]><script type="text/javascript" src="' . $player_path . '/demo/360-player/script/excanvas.js"></script><![endif]-->',
      );
      drupal_add_html_head($ie_js, 'audiofield');
      drupal_add_js($player_base_path . '/script/soundmanager2-nodebug-jsmin.js');

      //360 viewer 
      drupal_add_js($player_base_path . '/demo/360-player/script/berniecode-animator.js');
      drupal_add_js($player_base_path . '/demo/360-player/script/360player.js');
      drupal_add_css($player_base_path . '/demo/360-player/360player.css');

      $settings = 'soundManager.url = "' . $player_path . '/swf"; // directory where SM2 .SWFs live
        soundManager.useFastPolling = true; // increased JS callback frequency, combined with useHighPerformance = true
        soundManager.waitForWindowLoad = true;

        //so Firefox and others without MP3 support work 
        soundManager.preferFlash = true;

        // disable debug mode after development/testing..
        soundManager.debugMode = false;
        soundManager.onready(function () {
          soundManager.stopAll();
          threeSixtyPlayer.init();   
        });';
      drupal_add_js($settings, array('type' => 'inline', 'scope' => 'header'));
      $settings360 = "threeSixtyPlayer.config = {
              playNext: false, // stop after one sound, or play through list until end
              autoPlay: false, // start playing the first sound right away
              allowMultiple: false, // let many sounds play at once (false = one at a time)
              loadRingColor: '#ccc', // amount of sound which has loaded
              playRingColor: '#000', // amount of sound which has played
              backgroundRingColor: '#eee', // 'default' color shown underneath everything else
              animDuration: 500,
              animTransition: Animator.tx.bouncy // http://www.berniecode.com/writing/animator.html
           }";
      drupal_add_js($settings360, array('type' => 'inline', 'scope' => 'header'));
    }

    return ' 
    	<div id="sm2-container-real" class="ui360">
        <a href="' . $audio_file . '">' . $filename . '</a>
    	</div>';
  }
}
b3nji’s picture

I'm getting the following errors with the updated code posted in #7:

Warning: Missing argument 3 for audiofield_soundmanager2() in audiofield_soundmanager2() (line 211 of C:\Users\Ben\Sites\acquia-drupal\sites\all\modules\audiofield.players.inc).

Line 211: function audiofield_soundmanager2($player_path, $audio_file,$variables) {

Notice: Trying to get property of non-object in audiofield_soundmanager2() (line 222 of C:\Users\Ben\Sites\acquia-drupal\sites\all\modules\audiofield.players.inc).

Line 222: $filename = $variables['file']->filename;

gagarine’s picture

You have to use the patch #6 first and after replace the function.

ws.agency’s picture

Issue summary: View changes
Status: Needs review » Needs work

Needs work due to a latest bug fixes & patches applied.

Daniel.Moberly’s picture

Status: Needs work » Closed (outdated)

7.x version allows for the use of Sound Manager 2. See issue #2615240: Soundmanager 2 Players for discussion on adding additional Sound Manager 2 players.