同步操作将从 Gerald/h5player 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
$ bower install h5player
<script src="player-with-css.min.js"></script>
<div id="player"></div>
<script>
var player = new Player({
container: document.getElementById('player'),
image: 'http://example.com/path/to/default/image',
});
player.setSongs([
{
name: 'Song1',
url: 'http://example.com/path/to/song1.mp3',
}, {
name: 'Song2',
url: 'http://example.com/path/to/song2.mp3',
}
]);
player.play(0);
</script>
After loading dist/player-with-css.min.js
, there will be a global variable Player
.
Each player is built with new Player(options)
. options is an object with properties below:
container: required
refer to a DOM element to hold the player panel.
image: optional
path to the default image, shown when no image is assigned for the current song.
The recommended size is 130 * 130.
smallimage: optional
path to the default small image, shown when no image is assigned for the current song in simple theme.
The recommended size is 34 * 34.
theme: optional
currently there are two themes available: simple and normal. The default value is normal.
classes: optional
refer to a dict with custom classes of each button, the default values are:
classes: { list: 'fa fa-list', prev: 'fa fa-step-forward', play: 'fa fa-play', next: 'fa fa-step-forward', pause: 'fa fa-pause', } ``` Notice: the default values require Font-Awesome.
The Player
object has following methods:
setSongs(Array songs)
set playlist for the player, songs is a list of object
s with properties below:
[00:00]foo\n[00:05]bar\n...
.http://example.com/path/to/lyric
, the request URL will be http://example.com/path/to/lyric?jsonp=randomCallbackName
.play(int index)
start playing the index-th song.
When the play status is changed, a PlayerEvent
will be fired with its detail
set to an object with following attributes:
player
the Player
object that is related to this event
type
play
or pause
Normal theme:
Simple theme: (multiple players)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。