本文介绍了从soundcloud设置web audio api源节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何方法可以创建源节点(。

I would like to know if there is any way to create a source node ( https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#MediaElementAudioSourceNode) from a soundcloud track.

我对网络音频API很满意,但对于soundcloud sdk是新手,据我所知,它依赖于soundmanager2。那么也许有一些来自soundmanager2的选项?

I'm ok with the web audio API, but new to the soundcloud sdk, as far I understand it relies on soundmanager2. So maybe there is some options from soundmanager2 available?

问候

推荐答案

您可以请求一个曲目,然后使用 stream_url 属性,您可以为音频元素设置为 src ,用作MediaSourceNode。

You can request a track and then use stream_url property, that you can set as src for the audio element, to be used as MediaSourceNode.

这是一个示例代码:

var context = new webkitAudioContext(),
    audio = new Audio(),
    source,
    // `stream_url` you'd get from 
    // requesting http://api.soundcloud.com/tracks/6981096.json
    url = 'http://api.soundcloud.com/tracks/6981096/stream' +
          '?client_id=YOUR_CLIENT_ID';

audio.src = url;
source = context.createMediaElementSource(audio);
source.connect(context.destination);
source.mediaElement.play();

以下是实例:

这篇关于从soundcloud设置web audio api源节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 12:48