1 Star 0 Fork 38

anikin0617 / h5player

forked from Gerald / h5player 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

HTML5 Player

Bower

Installation

$ bower install h5player

Usage

<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>

Document

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 objects with properties below:

    • name: required
      string, the name of the song.
    • url: required
      string, a downloadable URL.
    • artist: optional
      string, the artist name.
    • duration: optional
      integer, length of the song in seconds.
    • image: optional
      string, path to the image (130 * 130 recommended) of the song.
    • smallimage: optional
      string, path to the small image (34 * 34 recommended) of the song, which is used in simple theme.
    • lyric: optional
      string, lyric data of the song. The data may be something like [00:00]foo\n[00:05]bar\n....
    • lyricjsonp: optional
      string, a JSONP URL to be used if lyric is not provided. If lyricjsonp is 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

Demos

Snapshots

Normal theme:

snapshot

Simple theme: (multiple players)

snapshot

空文件

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/anikin0617/h5player.git
git@gitee.com:anikin0617/h5player.git
anikin0617
h5player
h5player
master

搜索帮助