我定期播放一些音符.每一个都会延迟一个随机的毫秒数,从而产生刺耳的不规则效果.我如何解决它?
注意:只要它一致,我就会有一些延迟.
"实现你自己的小型SoundManager2替换,为时间敏感的播放进行了优化"的答案是可以的,如果你知道如何做到这一点:)但我试图避免在Flash中重写我的整个应用程序.
有关可听延迟为零的应用程序示例,请参阅基于闪存的ToneMatrix.
<head>
<title></title>
<script type="text/javascript"
src="http://www.schillmania.com/projects/soundmanager2/script/soundmanager2.js">
</script>
<script type="text/javascript">
soundManager.url = '.'
soundManager.flashVersion = 9
soundManager.useHighPerformance = true
soundManager.useFastPolling = true
soundManager.autoLoad = true
function recur(func, delay) {
window.setTimeout(function() { recur(func, delay); func(); }, delay)
}
soundManager.onload = function() {
var sound = soundManager.createSound("test", "test.mp3")
recur(function() { sound.play() }, 300)
}
</script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 如果设置了各种属性并且认为条件正常,则soundmanager2将使用html5音频而不是flash.
一旦soundmanager2决定了,SoundManager对象上是否有一个属性可以告诉我它是用于html5还是flash?
(我知道它在调试日志中提到它,但我正在寻找一个我可以查询的属性)
我正在使用SoundManager2的Web应用程序.在将我的头撞到墙上并且没有让我的音乐流式传输之后,我终于在创建新的SoundManager声音时切换了我的一些URL.
这是我以前使用的,虽然它会连接,但流将永远不会播放.
soundManager.createSound({
id: 'songId_1',
serverURL: 'rtmp://s3s5uvbmfjq6k1.cloudfront.net:1935/cfx/st',
url: 'hihi.m4a',
onconnect: function(connected){
alert(connected);
}
});
Run Code Online (Sandbox Code Playgroud)
然而,一旦我将其更改为此,它突然能够流式传输.
soundManager.createSound({
id:'test3',
serverURL:'rtmp://s3s5uvbmfjq6k1.cloudfront.net:1935/cfx/st',
url:'mp4:hihi.m4a'
});
Run Code Online (Sandbox Code Playgroud)
我不明白为什么第一个不起作用而第二个不起作用.我没有问题,serverURL是硬编码的,但url是动态的,可以是任意数量的音频格式,因此必须将其转换为有效的值才会对我有意义,除非有API这样做(我没有在Cloudfront中看到一个).有没有办法转换
song location/song name.ext
Run Code Online (Sandbox Code Playgroud)
进入它是正确的流媒体网址还是我需要使用其他播放器?
我的问题是相同的这一个在这里,但是因为这个问题一直没有解决,我不能消息PeeHaa私下问的答案,我会在这里再次问.
我已经成功查询了soundcloud api并获得了每首曲目的stream_url并将其添加到我的360播放器的所有href中(此处演示).我的元素代码看起来像这样:
<div class="ui360">
<a href="/path/to/an.mp3" data-title="Track title">play "an.mp3"</a>
</div>
Run Code Online (Sandbox Code Playgroud)
我有这个脚本来查找所有带有数据标题属性的标签,并根据stream_url给它们正确的href,但是当我尝试在浏览器中单击soundmanager图标并播放轨道时,它只会被重定向到. mp3网址.
SC.initialize({
client_id: 'MY_CLIENT_ID'
});
SC.get('/playlists/2450655', 'allow_redirects=False', function(playlist) {
var titles = $('.audio .ui360 a').each(function(index){
this.index = index;
});
for (var i = 0; i < playlist.tracks.length; i++) {
var id = '?client_id=MY_CLIENT_ID'
for (var j = 0; j < titles.length; j++) {
if (playlist.tracks[i].title === $(titles[j]).attr('data-title')) {
$(titles[j]).attr('href', playlist.tracks[i].stream_url+id)
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
有谁知道如何以这种方式获得正确的url播放soundcloud上的音轨?
我在我的网站上使用Soundmanager Mp3按钮.但是,我想使用Soundcloud Api通过Soundmanager流式传输音轨,而不是托管MP3.基本上,我想通过Soundmanager按钮流式传输Soundcloud链接.可能?
我已经尝试创建一个jQuery循环(下面),但仍然没有运气.
<ol>
<li><a class="sm2_button" href="http://soundcloud.com/....">Track Title</a>
</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
和jQuery
$("ol a").each(function()
{
var thisLink = $(this);
var track_url = this.href; // save href value of each link to 'track_url' i.e. soundcloud.com/...
this.href = this.href.replace(track_url, "#"); // replace href value with '#'
var consumer_key = 'My Consumer Key';
// now resolve the stream_url through Soundcloud's getJSON method
$.when($.getJSON('http://api.soundcloud.com/resolve?url=' + track_url + '&format=json&consumer_key=' + consumer_key + '&callback=?', function(track) {
url = track.stream_url + '?consumer_key=' + consumer_key;
})).done(function() {
// …Run Code Online (Sandbox Code Playgroud) 我使用SoundManager2在我的网站上播放声音.
现在,我想在每次用户播放声音时发送Google Analytics事件.
SoundManager2的文档说你可以通过设置属性来捕捉"on play"事件但是当使用360-ui-player时,这不起作用.
我像这样初始化SoundManager2:
<link rel="stylesheet" type="text/css" href="/app/sm/360/360player.css" />
<link rel="stylesheet" type="text/css" href="/app/sm/flashblock.css" />
<script src="/app/sm/360/berniecode-animator.js" type="text/javascript"></script>
<script src="/app/sm/soundmanager2-nodebug-jsmin.js" type="text/javascript"></script>
<script src="/app/sm/360/360player.js" type="text/javascript"></script>
<script type="text/javascript">
soundManager.url = '/app/sm/swf/';
threeSixtyPlayer.config = {
playNext: false,
autoPlay: false,
allowMultiple: false,
loadRingColor: '#ccc',
playRingColor: '#AB3C2E',
backgroundRingColor: '#eee',
animDuration: 500,
onplay: function() {
alert('Playing!'); // DOES NOT WORK!
},
animTransition: Animator.tx.veryBouncy
}
</script>
Run Code Online (Sandbox Code Playgroud)
有没有人有这个工作的解决方案?
我读到了人们在SoundManager源代码中更改了createSound()函数的解决方案,但我希望看到一个解决方案而不更改库.
我使用的是soundmanager2,我遇到了Safari问题.
我成功地将受保护的文件(在webroot之外)从PHP传输到Soundmanager2,使用类似这样的东西:
//check if user is logged in and has rights on $file
//if yes stream file
if (file_exists($file)) {
$filepath = $file;
$filesize = filesize($filepath);
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Disposition: attachment;filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary");
header('Content-Type: audio/mpeg');
header('Content-Length: '.$filesize);
@readfile($filepath);
exit(0);
}
Run Code Online (Sandbox Code Playgroud)
这在Firefox和Chrome上工作正常,mp3文件正在播放,但在Safari中我得到:
soundmanager2.js:1190basicMP3Sound0: Using HTML5
soundmanager2.js:1190basicMP3Sound0: play(): Attempting to load
soundmanager2.js:1190basicMP3Sound0: load (/privateaccess/index/1415)
soundmanager2.js:1190basicMP3Sound0: waiting
soundmanager2.js:1190basicMP3Sound0: loadstart
soundmanager2.js:1190basicMP3Sound0: loadedmetadata
soundmanager2.js:1190basicMP3Sound0: HTML5 error, code 3
soundmanager2.js:1188basicMP3Sound0: Failed to load / invalid sound? Zero-length duration reported. (/privateaccess/index/1415)
Run Code Online (Sandbox Code Playgroud)
我从PHP流式传输文件时只收到此错误,它正在使用webroot中的文件(由apache而不是PHP提供). …
这是我的代码,它没有发出任何警报,也没有返回任何好的东西:( 第一部分工作正常,但后记却没有 :( 我似乎无法弄清楚问题是什么..
this.getNextItem = function(o) {
// given <li> playlist item, find next <li> and then <a>
if (o.nextElementSibling) {
o = o.nextElementSibling;
}
else {
o = o.nextSibling;
}
while (o && o.className !== 'playerr') {
if (o.nextElementSibling) {
o = o.nextElementSibling;
} else {
o = o.nextSibling;
}
}
if(o){ if (o.className !== 'playerr') { //nodeName.toLowerCase()
return null;
} else {
alert(o.className);
alert(o.getElementsByTagName('a')[0]);
return o.getElementsByTagName('a')[0];
}}
};
Run Code Online (Sandbox Code Playgroud)
如果您想查看其http://beastdrops.com的完整上下文,请在控制台中运行 page("content2") 以获取新的“播放器”将歌曲转发到结尾,然后在即将更改为下一首歌曲时它不会...... :( 这就是这个脚本要做的
我是html中的音频新手.我找到了一些小javascript游戏的好例子.我想尝试在Internet Explorer中加载游戏,我得到:"此浏览器不支持Web api音频".
我找到了这个网站:http://caniuse.com/#feat=audio-api ,看起来像Internet Explorer不支持它.
我发现SoundManager 2似乎适用于所有浏览器.
我的问题是,有没有办法检测浏览器是否支持WebApiAudio,如果不支持则提供回退?
我希望能够在所有不同的浏览器上提供相同的功能,但我不知道如何在这一点上做到这一点.
一个不错的功能是能够同时播放多种声音,并具有可调音量(如爆炸).
我想创建一个helloworld,我可以在PC,Mac,Android和Ipad上运行.可能吗 ?
非常感谢我的多个问题.
我查看这个演示:http://www.cocos2d-x.org/wiki/MoonWarriors_-_Cocos2d-JS_Showcase 声音在Firefox中运行良好,但在Internet Explorer中只有音乐,而不是声音效果
javascript internet-explorer soundmanager2 html5-audio web-audio-api
我下载了一些代码,而不是在我的本地课堂上播放我的声音,调用另一个类来播放声音,我唯一的问题是它不允许我在手机上使用我的音量键调整音量而我的旧代码在我的本地课上允许我这样做.
以旧的方式,本地类有这个代码:
AudioManager mgr = (AudioManager) GameScreen_bugfix.this.getSystemService(Context.AUDIO_SERVICE);
float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
float volume = streamVolumeCurrent / streamVolumeMax;
soundPool.play(soundPoolMap.get(sound), volume, volume, 1, 0,1f);
Run Code Online (Sandbox Code Playgroud)
新代码如下所示:
public static void playSound(int index,float speed)
{
float streamVolume;
try {
streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
streamVolume = streamVolume / mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, 0, speed);
} catch (Exception e) {
e.printStackTrace();
//Log.v("THE ERROR", mSoundPoolMap+" "+index);
}
}
Run Code Online (Sandbox Code Playgroud)
所以我试着改变它:
AudioManager mgr = (AudioManager) SoundManager.getSystemService(Context.AUDIO_SERVICE);
float streamVolumeCurrent = mgr
.getStreamVolume(AudioManager.STREAM_MUSIC);
float streamVolumeMax = mgr
.getStreamMaxVolume(AudioManager.STREAM_MUSIC); …Run Code Online (Sandbox Code Playgroud) soundmanager2 ×10
javascript ×6
audio ×3
soundcloud ×2
android ×1
html5 ×1
html5-audio ×1
jquery ×1
latency ×1
php ×1
rtmp ×1
safari ×1
soundpool ×1
streaming ×1