Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andycall/mobile-audio-player
跨平台音频播放器
https://github.com/andycall/mobile-audio-player
Last synced: 6 days ago
JSON representation
跨平台音频播放器
- Host: GitHub
- URL: https://github.com/andycall/mobile-audio-player
- Owner: andycall
- Created: 2016-03-16T15:27:17.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-19T08:05:53.000Z (almost 9 years ago)
- Last Synced: 2024-10-19T04:30:36.211Z (2 months ago)
- Language: JavaScript
- Size: 6.8 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mobile-audio-player
跨平台音频播放器## 使用方式
```javascript
var player = $('#audioPlayer').audioPlayer({
controls: true, // 使用默认的控制界面
loop: false, // 重播
debug: false, // 开启debug输出
src: 'http://localhost:9020/halfbottle.mp3', // 默认的音频播放地址
onSrcChange: function (e, src) {
console.log('src change', src);
$('#player_status').append('src change: ' + src + '
');
},
onAudioEnd: function (e) {
console.log('this sound is end!');
$('#player_status').append('sound is end
');
},
onPlaying: function (e, second) {
console.log('current played', second);
$('#played').html(second.toFixed(2) + 's');
},
onPause: function (e, src) {
console.log('sound paused', src);
$('#player_status').append('sound pause: ' + src + '
');
},
onPlay: function (e, src) {
console.log('sound is going to play!', src);
$('#player_status').append('sound is going to play: ' + src + '
')
},
onError: function (e, error) {
console.log(error);
},
selector: {
played: '#played', // 显示播放进度
playButton: '.play-button' // 播放按钮选择器
}
});```
## 播放控制
假如目前播放的地址为 `http://localhost:9020/halfbottle.mp3`
player.play('http://localhost:9020/halfbottle.mp3') // 传入相同的地址可以控制播放与暂停
var button = document.querySelector('.play-button');
player.play('http://localhost:9020/halfbottle.mp3', button); // 传入播放按钮的DOM对象就能为该DOM对象修改播放进度