Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 65 additions & 8 deletions extensions/chrome/coplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@

// Supported websites: Youku, SohuTV, Tudou, TencentVideo, iQiyi, YouTube, ACFun, bilibili, MGTV, Vimeo
let host = location.host.match(
/(?:^|\.)(youku\.com|sohu\.com|tudou\.com|qq\.com|iqiyi\.com|youtube\.com|acfun\.cn|bilibili\.com|mgtv\.com|vimeo\.com)(?:\/|$)/i
/(?:^|\.)(youku\.com|sohu\.com|tudou\.com|qq\.com|iqiyi\.com|youtube\.com|acfun\.cn|bilibili\.com|mgtv\.com|vimeo\.com|pan\.baidu\.com)(?:\/|$)/i
);
if (!host) {
return;
}

host = host[1].split('.')[0];

/**
Expand Down Expand Up @@ -148,6 +149,49 @@
* Player adaptor layer
*/
let playerAdaptor = {};
playerAdaptor.pan = {
prepare() {
let component = undefined;
let that = this
function WaitForReady() {
if (typeof(videojs) == "undefined") {
return setTimeout(WaitForReady, 1000);
}
component = videojs.getPlayers("video-player").html5player;
console.log(component)

if (typeof(component) == "undefined") {
console.log("undefined")
return setTimeout(WaitForReady, 1000);
}
component = videojs.getPlayers("video-player").html5player;
that._player = component.tech_
}
WaitForReady();
},
play() {
this._player.play();
},
pause() {
this._player.pause();
},
seek(sec) {
this._player.setCurrentTime(sec);
},
isReady() {
return this._player.readyState() !== -1;
},
getTime() {
return this._player.currentTime();
},
toggleFullscreen() {
if (fullscreen()) {
this._player.exitFullScreen();
} else {
this._player.enterFullScreen();
}
}
};
playerAdaptor.youku = {
prepare() {
this._player = window.videoPlayer;
Expand Down Expand Up @@ -512,6 +556,14 @@
});
on(local, 'click', () => {});

let refresh = create('button', main, {
id: getId('refresh'),
innerHTML: `${icons['sync']}`
});
on(refresh, 'click', function() {
initPeer()
});

let remote = create('input', main, {
id: getId('remote'),
type: 'text',
Expand Down Expand Up @@ -594,6 +646,7 @@
coplay.ui = {
main,
local,
refresh,
remote,
connect,
disconnect,
Expand Down Expand Up @@ -834,10 +887,10 @@
c.send(pack('PATH', getPath()));
break;
case 'PATH':
if (p.data !== getPath()) {
console.error('Not on the same page.');
c.close();
}
// if (p.data !== getPath()) {
// console.error('Not on the same page.');
// c.close();
// }
break;
case 'MSG':
console.log('Remote: ' + p.data);
Expand Down Expand Up @@ -905,9 +958,13 @@
reliable: false
});

c.on('open', function() {
connect(c);
});
try{
c.on('open', function() {
connect(c);
});
} catch (err) {
alert("peerId 已过期,请重新获取")
}
};

coplay.disconnect = function() {
Expand Down
2 changes: 1 addition & 1 deletion extensions/chrome/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function checkAutoInject() {
url: [
{
urlMatches:
'(?:^|.)(youku.com|sohu.com|tudou.com|qq.com|iqiyi.com|youtube.com|acfun.cn|bilibili.com|mgtv.com|vimeo.com)(?:/|$)'
'(?:^|.)(youku.com|sohu.com|tudou.com|qq.com|iqiyi.com|youtube.com|acfun.cn|bilibili.com|mgtv.com|vimeo.com|pan.baidu.com)(?:/|$)'
}
]
});
Expand Down
1 change: 1 addition & 0 deletions extensions/chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"https://*.mgtv.com/*",
"http://*.vimeo.com/*",
"https://*.vimeo.com/*",
"https://pan.baidu.com/*",
"activeTab",
"webNavigation",
"storage",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 64 additions & 8 deletions src/coplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

// Supported websites: Youku, SohuTV, Tudou, TencentVideo, iQiyi, YouTube, ACFun, bilibili, MGTV, Vimeo
let host = location.host.match(
/(?:^|\.)(youku\.com|sohu\.com|tudou\.com|qq\.com|iqiyi\.com|youtube\.com|acfun\.cn|bilibili\.com|mgtv\.com|vimeo\.com)(?:\/|$)/i
/(?:^|\.)(youku\.com|sohu\.com|tudou\.com|qq\.com|iqiyi\.com|youtube\.com|acfun\.cn|bilibili\.com|mgtv\.com|vimeo\.com|pan\.baidu\.com)(?:\/|$)/i
);
if (!host) {
return;
Expand Down Expand Up @@ -148,6 +148,49 @@
* Player adaptor layer
*/
let playerAdaptor = {};
playerAdaptor.pan = {
prepare() {
let component = undefined;
let that = this
function WaitForReady() {
if (typeof(videojs) == "undefined") {
return setTimeout(WaitForReady, 1000);
}
component = videojs.getPlayers("video-player").html5player;
console.log(component)

if (typeof(component) == "undefined") {
console.log("undefined")
return setTimeout(WaitForReady, 1000);
}
component = videojs.getPlayers("video-player").html5player;
that._player = component.tech_
}
WaitForReady();
},
play() {
this._player.play();
},
pause() {
this._player.pause();
},
seek(sec) {
this._player.setCurrentTime(sec);
},
isReady() {
return this._player.readyState() !== -1;
},
getTime() {
return this._player.currentTime();
},
toggleFullscreen() {
if (fullscreen()) {
this._player.exitFullScreen();
} else {
this._player.enterFullScreen();
}
}
};
playerAdaptor.youku = {
prepare() {
this._player = window.videoPlayer;
Expand Down Expand Up @@ -512,6 +555,14 @@
});
on(local, 'click', () => {});

let refresh = create('button', main, {
id: getId('refresh'),
innerHTML: `${icons['sync']}`
});
on(refresh, 'click', function() {
initPeer()
});

let remote = create('input', main, {
id: getId('remote'),
type: 'text',
Expand Down Expand Up @@ -594,6 +645,7 @@
coplay.ui = {
main,
local,
refresh,
remote,
connect,
disconnect,
Expand Down Expand Up @@ -834,10 +886,10 @@
c.send(pack('PATH', getPath()));
break;
case 'PATH':
if (p.data !== getPath()) {
console.error('Not on the same page.');
c.close();
}
// if (p.data !== getPath()) {
// console.error('Not on the same page.');
// c.close();
// }
break;
case 'MSG':
console.log('Remote: ' + p.data);
Expand Down Expand Up @@ -905,9 +957,13 @@
reliable: false
});

c.on('open', function() {
connect(c);
});
try{
c.on('open', function() {
connect(c);
});
} catch (err) {
alert("peerId 已过期,请重新获取")
}
};

coplay.disconnect = function() {
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function checkAutoInject() {
url: [
{
urlMatches:
'(?:^|.)(youku.com|sohu.com|tudou.com|qq.com|iqiyi.com|youtube.com|acfun.cn|bilibili.com|mgtv.com|vimeo.com)(?:/|$)'
'(?:^|.)(youku.com|sohu.com|tudou.com|qq.com|iqiyi.com|youtube.com|acfun.cn|bilibili.com|mgtv.com|vimeo.com|pan.baidu.com)(?:/|$)'
}
]
});
Expand Down