如何让Soundcloud文件与Sound Manager 2一起使用?

时间:2013-04-12 23:33:41

标签: javascript html audio-streaming soundmanager2

我目前使用声音管理器的设置适用于我的所有mp3链接,除了具有soundcloud源的链接。不确定我做错了什么,有人看到我的代码有问题吗?

<!-- Page player core CSS -->
<link rel="stylesheet" type="text/css" href="soundmanager2/page-player.css" />

<!-- soundManager.useFlashBlock: related CSS -->
<link rel="stylesheet" type="text/css" href="soundmanager2/flashblock.css" />

<!-- optional: annotations/sub-tracks/notes, and alternate themes -->
<link rel="stylesheet" type="text/css" href="soundmanager2/optional-annotations.css" />
<link rel="stylesheet" type="text/css" href="soundmanager2/optional-themes.css" />



<!-- soundManager API -->
<script src="soundmanager2/soundmanager2.js"></script>

<script>


soundManager.setup({
  flashVersion: 9,
  preferFlash: true, // for visualization effects
  useHighPerformance: true, // keep flash on screen, boost performance
  wmode: 'transparent', // transparent SWF, if possible
  url: 'soundmanager2/'
});

// custom page player configuration

var PP_CONFIG = {
  autoStart: false,      // begin playing first sound when page loads
  playNext: true,        // stop after one sound, or play through list until end
  useThrottling: false,  // try to rate-limit potentially-expensive calls (eg. dragging position around)</span>
  usePeakData: true,     // [Flash 9 only] whether or not to show peak data (left/right channel values) - nor noticable on CPU
  useWaveformData: false,// [Flash 9 only] show raw waveform data - WARNING: LIKELY VERY CPU-HEAVY
  useEQData: false,      // [Flash 9 only] show EQ (frequency spectrum) data
  useFavIcon: false     // try to apply peakData to address bar (Firefox + Opera) - performance note: appears to make Firefox 3 do some temporary, heavy disk access/swapping/garbage collection at first(?) - may be too heavy on CPU
}


</script>

<!-- Page player main script -->
<script src="soundmanager2/page-player.js"></script>

然后我在这里使用它

<div>

 <ul class="playlist">


 <li> <a href="http://api.soundcloud.com/tracks/63928998/stream?client_id=bcc10d97babdd9960f823530831e0eb9d&q">SongName</a></li>


 </ul>

 <div id="control-template">
  <!-- control markup inserted dynamically after each link -->
  <div class="controls">
   <div class="statusbar">
    <div class="loading"></div>
     <div class="position"></div>
   </div>
  </div>
  <div class="timing">
   <div id="sm2_timing" class="timing-data">
    <span class="sm2_position">%s1</span> / <span class="sm2_total">%s2</span></div>
  </div>
  <div class="peak">
   <div class="peak-box"><span class="l"></span><span class="r"></span>
   </div>
  </div>
 </div>

 <div id="spectrum-container" class="spectrum-container">
  <div class="spectrum-box">
   <div class="spectrum"></div>
  </div>
 </div> 

1 个答案:

答案 0 :(得分:0)

简而言之,您的SoundCloud链接不是指向.mp3文件的直接链接,而是指向其API的链接,然后返回指向文件的一次性链接。

它类似于文件共享网站上文件的链接,您可以获得指向该网页的链接,该网页会生成一次性文件链接,以防止热链接。

因此,您当前的设置无法直接在浏览器中播放SoundCloud链接。