HTML5规定的行为,HTML5音频行为

I don't have an ICS phone to try it out, but here is what I would do:

pause obviously keeps track of the audio time position.

4.0 seems to automatically resume where you paused the audio file

So instead of pausing you could stop your audio file.

Unfortunately, stop isn't supported by HTML5.

You have a tricky solution:

pause audio

store the position: trackPos = myTrack.currentTime;

store volume: trackVol = myTrack.volume;

mute it: myTrack.volume = 0;

Then when the user comes back and hits play again:

if trackPos exists

set the starting position to trackPos: myTrack.currentTime = trackPos;

play

mytrack.volume = trackVol;

delete window.trackPos;

This is tricky but should work if you are using JavaScript controls.

If you use native controls though play and pause would be managed by the browser's interface. Then you should just store the position and start getting REAL dirty:

remove the sources:

myTrack.removeChid( yourSRCs )

restore your SRCs and position on focus

wait for the user to play

That's a quick and dirty draft, not tested. But it should work

///EDIT///

A working Javascript demo, at least on my desktop. Try it on your ICS:

JSFiddle

(save the file, I guess you can't launch jsfiddle properly on a phone)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值