https://github.com/ykws/android-webview-example
Play audio on Android WebView
https://github.com/ykws/android-webview-example
android audio webview
Last synced: 10 months ago
JSON representation
Play audio on Android WebView
- Host: GitHub
- URL: https://github.com/ykws/android-webview-example
- Owner: ykws
- Created: 2018-10-03T02:02:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-03T02:37:14.000Z (over 7 years ago)
- Last Synced: 2025-01-28T13:50:35.945Z (12 months ago)
- Topics: android, audio, webview
- Language: Java
- Homepage:
- Size: 87.9 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Play audio on Android WebView
Play audio on page finished or resume application, and pause audio on pause application, if target web page implements javascript function `playAudio` and `pauseAudio`.
## Server Side JavaScript Function Example
```javascript
var audio;
var playAudio = function() {
audio.play();
}
var pauseAudio = function() {
audio.pause();
}
$(document).ready(function() {
audio = new Audio('./sample.mp3');
audio.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);
});
```