2012-09-04 40 views
5

Tôi đã cố gắng sử dụng ví dụ được đưa ra trên trang Blog Soundcloud này để tôi có thể đặt âm lượng thấp hơn. http://developers.soundcloud.com/blog/html5-widget-apiĐiều khiển Soundcloud HTML5 Widget Player Volume

Tôi chỉ thay đổi kích thước iframe và src = thành danh sách phát và đặt.Volume thành 10 để tôi có thể nhận thấy sự khác biệt nếu nó hoạt động. Cho đến giờ, không có khối lượng thay đổi nào ở mức 100%

Tôi đã thử nó với và không đặt các phần sau vào phần đầu mẫu của tôi. Có vẻ không quan trọng.

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

Đây là mã mà tôi điều chỉnh từ ví dụ Soundcloud:

<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> 

Dưới đây là các trang web Joomla nơi mã này đang hoạt động. http://mediaservicesnyc.com/

Ai đó có thể vui lòng giúp tôi hiểu những gì tôi thiếu để kiểm soát âm lượng.

Đây có phải là cuộc xung đột gay gắt không? Nếu vậy, bất kỳ suy nghĩ về cách giải quyết nó?

Trân trọng, Eric

Trả lời

6

phạm vi khối lượng thực sự là 0-1, điều này được nói sai trong tài liệu. Vì vậy, nếu bạn muốn đặt âm lượng thành 10%, bạn sẽ cần điều này:

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

widget.setVolume(0.1); 
0

Câu trả lời trước đó không còn chính xác nữa. Api setVolume() đã được sửa/thay đổi để lấy một int trong khoảng từ 0 đến 100.

Tôi tình cờ gặp câu hỏi này để thay đổi nhanh chóng khối lượng của một khung nội tuyến SoundCloud được nhúng bằng bảng điều khiển chrome. Tôi tạo ra một nắm tay nhanh chóng cho bản thân mình. 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 
Các vấn đề liên quan