如何在声音管理器中返回歌曲持续时间
如何使用函数返回声音管理器中的歌曲持续时间?
function item_duration(){
var song_item = soundManager.createSound({
id:'etc',
url:'etc',
onload: function() {
if(this.readyState == 'loaded' ||
this.readyState == 'complete' ||
this.readyState == 3){
return = this.duration;
}
}
});
song_item.load();
}
这是我的尝试,但不起作用
How can i return song duration in soundmanager with function ?
function item_duration(){
var song_item = soundManager.createSound({
id:'etc',
url:'etc',
onload: function() {
if(this.readyState == 'loaded' ||
this.readyState == 'complete' ||
this.readyState == 3){
return = this.duration;
}
}
});
song_item.load();
}
This is my try, but it's not working
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
return
是一个关键字,而不是一个变量。return this.duration;
是你想要的;跳过=
(这只会给你一个语法错误)......但这并没有多大帮助,因为你要把它返回到哪里?您需要调用另一个函数,该函数对持续时间进行处理。
item_duration
函数在调用createSound
后立即返回,然后异步加载文件尝试如下
return
is a keyword, not a variable.return this.duration;
is what you'd want; skip the=
(which will just give you a syntax error)… but that won't help much, because where are you returning it to? You'll need to call another function, that does something with the duration. The
item_duration
function returns immediately after callingcreateSound
, which then loads the file asynchronouslyTry something like this