Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
谢庭 authored and 谢庭 committed Sep 24, 2017
1 parent a05eb66 commit 9752277
Show file tree
Hide file tree
Showing 12 changed files with 713 additions and 328 deletions.
Binary file modified dist/.DS_Store
Binary file not shown.
2 changes: 0 additions & 2 deletions dist/pear-player.min.js

This file was deleted.

9 changes: 6 additions & 3 deletions examples/cp.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
<!--<video id="pearvideo" src="https://qq.webrtc.win/tv/Pear-Demo-Yosemite_National_Park.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/free/planet.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/free/SoundOfMusic.mp4" controls>-->
<video id="pearvideo" src="https://qq.webrtc.win/free/Pear-Demo-sintel-1024-surround.mp4" controls>
<!--<video id="pearvideo" src="https://qq.webrtc.win/free/Pear-Demo-sintel-1024-surround.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/free/Pear-Demo-SoundOfMusic_60.mp4" controls>-->
<!--<video id="pearvideo" src="http://p2p.ali.fastweb.com.cn/test.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/music/Say_You_Wont_Let_Go.mp4" controls>-->
<video id="pearvideo" src="https://p2p.ali.fastweb.com.cn/test2.mp4" controls>
</video>
</div>
<!--<script src="https://cdn.jsdelivr.net/npm/pearplayer@latest/dist/pear-player.min.js"></script>-->
Expand All @@ -23,7 +26,7 @@
var xhr = new XMLHttpRequest();
xhr.open("POST", 'https://api.webrtc.win:6601/v1/customer/login');
var data = JSON.stringify({
user:'test',
username:'test',
password:'123456'
});
xhr.timeout = 2000;
Expand All @@ -41,7 +44,7 @@
interval: 5000, //滑动窗口的时间间隔,单位毫秒,默认10s
auto: false, //true为连续下载buffer,false则是只有当前播放时间与已缓冲时间小于slideInterval时下载buffer,默认false
slideInterval: 20, //当前播放时间与已缓冲时间小于这个数值时触发窗口滑动,单位秒,默认20s
useDataChannel: true, //是否开启data channel,默认true
useDataChannel: false, //是否开启data channel,默认true
dataChannels: 10, //创建data channel的最大数量,默认2
useTorrent: true, //是否开启Browser P2P(基于Webtorrent),默认true
// magnetURI: magnetURI, //可手动传入magnetURI,需先将useTorrent设为true
Expand Down
16 changes: 11 additions & 5 deletions examples/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
<body>
<div id="main">
<video id="pearvideo" src="https://qq.webrtc.win/tv/Pear-Demo-Yosemite_National_Park.mp4" controls>
<!--<video id="pearvideo" src="https://qq.webrtc.win/free/planet.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/tv/Pear-demo-your-name.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/newifi/Pear-Demo-planet.earth.ii.s01e04.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/free/Pear-Demo-SoundOfMusic_172.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/free/SoundOfMusic.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/free/Pear-Demo-sintel-1024-surround.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/newifi/Pear-Demo-planet.earth.ii.s01e04.720p.ffmpeg.mp4" controls>-->
<!--<video id="pearvideo" src="https://qq.webrtc.win/music/Say_You_Wont_Let_Go.mp4" controls>-->
</video>
</div>
<!--<script src="https://cdn.jsdelivr.net/npm/pearplayer@latest/dist/pear-player.min.js"></script>-->
Expand All @@ -29,13 +30,14 @@
interval: 5000, //滑动窗口的时间间隔,单位毫秒,默认10s
slideInterval: 20, //当前播放时间与已缓冲时间小于这个数值时触发窗口滑动,单位秒,默认20s
useDataChannel: true, //是否开启data channel,默认true
dataChannels: 10, //创建data channel的最大数量,默认10
dataChannels: 20, //创建data channel的最大数量,默认10
useTorrent: true, //是否开启Browser P2P(基于Webtorrent),默认true
// magnetURI: magnetURI, //可手动传入magnetURI,需先将useTorrent设为true
// trackers:["wss://tracker.openwebtorrent.com"], //可手动传入tracker服务器,需先将useTorrent设为true
sources: [],
//指定下载源,增加这个字段后pearplayer不会再向后台请求节点,建议下载源多于5个以保证流畅播放
useMonitor: true //是否开启monitor,会稍微影响性能,默认false
useMonitor: true, //是否开启monitor,会稍微影响性能,默认false
chunkSize: 1024*1024
});

player.on('exception', onException); //播放器出现异常时的回调函数
Expand All @@ -48,7 +50,8 @@
player.on('done', onDone);         //结束下载时触发
player.on('traffic', onTraffic); //节点流量统计,每次下载buffer都会触发该事件
player.on('sourcemap', onSourceMap); //记录每个buffer的下载源类型,其中s: server n: node d: data channel b: browser

player.on('metadata', onMetaData);
console.log('7777777777777777');
function onBegin(fileLength, chunks) {
console.log('start downloading buffer by first aid, file length is:' + fileLength/1024/1024 + ' total chunks:' + chunks);
}
Expand Down Expand Up @@ -84,6 +87,7 @@
}
function onBufferSources(bufferSources) { //s: server n: node d: data channel b: browser
console.log('Current Buffer Sources:' + bufferSources);
console.log(JSON.stringify(player.debugInfo));
}
function onTraffic(mac, size, type) {
console.log('type:'+type+' mac:'+mac+' downloaded:'+size/1024/1024+'MB');
Expand All @@ -92,7 +96,9 @@
function onSourceMap(sourceType, index) {
console.log('Received source type:' + sourceType + ' index:' + index);
}

function onMetaData(metadata) {
console.log('metadata bitrate:'+metadata.bitrate/1024+' KB/s');
}
</script>
</body>

Expand Down
Loading

0 comments on commit 9752277

Please sign in to comment.