如何在 Titanium 中玩游戏时返回 5 秒,点击按钮就会发生这种情况
我有以下代码。
var file = recording.stop();
sound = Titanium.Media.createSound({sound:file});
sound.play();
sound.getTime(); // This will return the current time position of the audio.
var goBack = Titanium.UI.createButton({title:'Go Back',height:40,width:200,top:230});
goBack.addEventListener('click',function(){
if(sound.playing){
Ti.API.info(sound.getTime()); // If this prints 25 secs.
}
});
win.add(goBack);
假设当前的 getTime() 返回 25,并且我需要在单击按钮时播放 20 秒后的音频。
我该怎么做?
我可以使用这样的东西
setTime = sound.getTime() - 5
但是我们如何将浮点值传递给 sound.setTime ?
还有有没有办法添加搜索栏来指示声音对象的播放状态?
I have the following code.
var file = recording.stop();
sound = Titanium.Media.createSound({sound:file});
sound.play();
sound.getTime(); // This will return the current time position of the audio.
var goBack = Titanium.UI.createButton({title:'Go Back',height:40,width:200,top:230});
goBack.addEventListener('click',function(){
if(sound.playing){
Ti.API.info(sound.getTime()); // If this prints 25 secs.
}
});
win.add(goBack);
Assuming that currect getTime()
returns 25 and i need to play the audio from 20 secs on button click.
How do i do this?
I can use something like this
setTime = sound.getTime() - 5
But How do we pass the float value to sound.setTime?
And also Is there any way to add seek bar to indicate the play status of the sound object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以像这样设置时间值:
您可以像这样添加进度条:
You can set the time value like this:
You can add a progress bar like this: