【问题标题】:Audio Pause while typing & play while stop typing打字时暂停音频,停止打字时播放
【发布时间】:2018-04-29 14:48:36
【问题描述】:

这是使用“Alt+P”按键暂停和播放的音频播放器脚本。

https://github.com/jonmbake/jquery-html5-audioplayer

我想添加一个文本框,在我输入时我希望音频自动暂停,当我停止输入时我希望音频开始播放。

【问题讨论】:

  • 请添加您遇到问题的代码。

标签: javascript jquery audio audio-player


【解决方案1】:
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Audio Player Demo</title>
    <meta name="description" content="Demo of the Audio Player jQuery plugin.">
    <meta name="author" content="Jon Bake">
    <link rel="stylesheet" href="src/jquery.audio-player.css">
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
  </head>
  <body>
    <div id="audio-player"></div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="src/jquery.audio-player.js"></script>
    <script>
      $('#audio-player').audioPlayer();
      //togglePlay
    </script>
    <script>

$(document).ready(function(){
    $("input").keypress(function(){       
// I want to call the function in the src/jquery.audio-player.js
// when the play and pause button is executed with below
// this.$playPause.on("click", this.togglePlay.bind(this));
// How to enable togglePlay() when we keep typing and stoping the typing        
    });
});
</script>

    <input id="target" type="text" value="">
  </body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-13
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多