2012-09-04 13 views
5

पर नियंत्रण मैं इस ध्वनि क्लाउड ब्लॉग पेज पर दिए गए उदाहरण का उपयोग करने का प्रयास कर रहा हूं, इसलिए मैं वॉल्यूम को कम कर सकता हूं। http://developers.soundcloud.com/blog/html5-widget-apiध्वनि क्लाउड HTML5 विजेट प्लेयर वॉल्यूम

मैं केवल 10 के लिए अपनी प्लेलिस्ट और set.Volume करने के लिए iframe आकार और src = बदल तो मैं अंतर नोटिस सकता है अगर यह काम किया। अब तक कोई भी बदलाव वॉल्यूम 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> 

यहाँ कोड है कि मैं Soundcloud उदाहरण से समायोजित है। http://mediaservicesnyc.com/

क्या कोई मुझे समझने में मदद कर सकता है कि मुझे वॉल्यूम को नियंत्रित करने की क्या कमी है।

क्या यह एक jquery संघर्ष है? यदि हां, तो इसे हल करने के तरीके पर कोई विचार?

निष्ठा से, एरिक

उत्तर

6

मात्रा रेंज इस गलत तरीके से दस्तावेज में कहा गया है, 0 से 1 तक वास्तव में है। आप 10% करने के लिए मात्रा सेट करना चाहते हैं तो अगर आप इस की आवश्यकता होगी:

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

widget.setVolume(0.1); 
0

पिछले जवाब अब सही है। सेटवॉल्यूम() एपीआई को 0 और 100 के बीच एक int में लेने के लिए तय/बदला गया है।

मैंने क्रोम कंसोल का उपयोग करके एम्बेडेड ध्वनि क्लाउड आईफ्रेम की मात्रा को तेज़ी से बदलने की कोशिश कर इस प्रश्न पर ठोकर खाई। मैंने अपने लिए एक त्वरित गलती बनाई। 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 
संबंधित मुद्दे