2012-09-04 3 views
5

볼륨을 더 낮게 설정할 수 있도록이 Soundcloud 블로그 페이지에 제공된 예제를 사용하려고 시도했습니다. http://developers.soundcloud.com/blog/html5-widget-apiSoundcloud HTML5 위젯 플레이어 볼륨 제어

나는 단지 iframe 크기를 변경하고 src = playlist로 설정하고 set.Volume을 10으로 설정하여 효과가있는 경우 차이점을 알 수있었습니다. 지금까지 변경 볼륨이 아직 100 %가되지 않았습니다.

템플릿 템플릿의 헤드에 다음을 삽입하지 않고 시도했습니다. 상관 없어.

다음
<iframe id="sc-widget" width="350" height="332" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F1417174&auto_play=true&show_artwork=false&color=37415f"></iframe> 

    <script src="http://w.soundcloud.com/player/api.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
    (function(){ 
    var widgetIframe = document.getElementById('sc-widget'), 
     widget  = SC.Widget(widgetIframe); 

    widget.bind(SC.Widget.Events.READY, function() { 
     widget.bind(SC.Widget.Events.PLAY, function() { 
     // get information about currently playing sound 
     widget.getCurrentSound(function(currentSound) { 
      console.log('sound ' + currentSound.get('') + 'began to play'); 
     }); 
     }); 
     // get current level of volume 
     widget.getVolume(function(volume) { 
     console.log('current volume value is ' + volume); 
     }); 
     // set new volume level 
     widget.setVolume(10); 
    }); 

    }()); 
    </script> 

이 코드는 라이브 인 줌라 사이트입니다 : 여기

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 

내가 사운드 클라우드의 예에서 조정 코드입니다. http://mediaservicesnyc.com/

누군가 내가 볼륨을 제어 할 수없는 것을 이해할 수 있도록 도와주십시오.

jquery 충돌입니까? 그렇다면 그것을 해결하는 방법에 대한 생각?

감사

, 에릭

답변

6

볼륨 범위는이이 문서에 잘못 적혀있다, 0에서 1 사실이다. 따라서 볼륨을 10 %로 설정하려면 다음이 필요합니다.

var widgetIframe = document.getElementById('sc-widget'), 
widget  = SC.Widget(widgetIframe); 

widget.setVolume(0.1); 
0

이전 대답은 정확하지 않습니다. setVolume() api가 0에서 100 사이의 int 값을 갖도록 고정/변경되었습니다.

크롬 콘솔을 사용하여 포함 된 SoundCloud iframe의 볼륨을 빠르게 변경하려고 할 때이 질문에 마주 쳤습니다. 나는 나 자신을위한 빠른 요지를 만들었다. https://gist.github.com/propagated/78aaedfbc0c23add7691bb975b51a3ff

//load soundcloud js api if needed 
var script = document.createElement('script'); 
script.type = 'text/javascript'; 
script.src = 'http://w.soundcloud.com/player/api.js'; 
document.head.appendChild(script); 

//get the id of the player iframe or inject it using chrome 
var id = 'scplayer', 
    widgetIframe = document.getElementById(id), 
    fixWidget = SC.Widget(widgetIframe); 
fixWidget.setVolume(50); //% between 1 and 100