在mac 谷歌瀏覽器下,提示錯(cuò)誤play() failed because the user didn't interact with the document first.
? ?componentDidMount()?{
????????$("#player").jPlayer({
????????????ready:??function(){
????????????????$(this).jPlayer("setMedia",?{
????????????????????'mp3':?'http://oj4t8z2d5.bkt.clouddn.com/%E9%AD%94%E9%AC%BC%E4%B8%AD%E7%9A%84%E5%A4%A9%E4%BD%BF.mp3',
????????????????}).jPlayer('play');
????????????},
????????????supplied:?"mp3",
????????????vmode:?"window",
????????????size:{
????????????????width:"640px",
????????????????height:"396px",
????????????????cssClass:"jp-video-360p"
??????????????},
????????});
????????$('#player').bind($.jPlayer.event.timeupdate,?e?=>?{
????????????this.setState({
????????????????progress:?Math.round(e.jPlayer.status.currentTime)
????????????})
????????})
????}?
2018-12-18
這是chrome瀏覽器在今年4月份的自動(dòng)播放策略,在頁(yè)面沒(méi)有產(chǎn)生用戶交互時(shí)時(shí)不能進(jìn)行自動(dòng)播放的,可以先讓用戶點(diǎn)擊再進(jìn)行播放