简体   繁体   中英

MediaElement.js stop autoplay in a page

I use mejsaudio in my wordpress site header. I use it with this code;

[mejsaudio src="http://specialholidayinturkey.org/special-fon.mp3" volume="1" autoplay="true" loop="true"] 

so it starts in everypage in my site.

But I want to stop it in my video page. I need a java code to stop it i think.

Pls help me.

尝试使用本机HTML5方法暂停:

$('#myAudioElement').pause();

I solved it with this code

<script>
function aud_play_pause() {
  var myAudio = document.getElementById("wp_mep_1");
  if (myAudio.play) {
    myAudio.pause();
  } else {
    myAudio.pause();
  }
}
</script>
<body onLoad="aud_play_pause()">

thanks for your answer. "wp_mep_1" is my audio id that i saw in my source code of web site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM