youtube player
This commit is contained in:
@@ -13,7 +13,7 @@ export default function TReactPlayer({mediaEventsMap=handledMediaEventsMap, vide
|
||||
if(videoRef ){
|
||||
const videoNode = playerRef.current.getInternalPlayer();
|
||||
videoRef(videoNode);
|
||||
if(!Object.prototype.hasOwnProperty.call(videoNode, "proportionPlayed")){
|
||||
if(videoNode.tagName && !Object.prototype.hasOwnProperty.call(videoNode, "proportionPlayed")){
|
||||
Object.defineProperties(videoNode, {
|
||||
'error': {
|
||||
get: function() {
|
||||
@@ -36,6 +36,52 @@ export default function TReactPlayer({mediaEventsMap=handledMediaEventsMap, vide
|
||||
}
|
||||
}
|
||||
});
|
||||
}else if(!Object.prototype.hasOwnProperty.call(videoNode, "proportionPlayed")){//youtube
|
||||
window.videoNode = videoNode;
|
||||
videoNode.play = videoNode.playVideo;
|
||||
videoNode.pause = videoNode.pauseVideo;
|
||||
videoNode.seek = videoNode.seekTo;
|
||||
Object.defineProperties(videoNode, {
|
||||
'currentTime': {
|
||||
get: function() {
|
||||
return videoNode.getCurrentTime();
|
||||
},
|
||||
set: function(time){
|
||||
videoNode.seekTo(time);
|
||||
}
|
||||
},
|
||||
'duration':{
|
||||
get: function() {
|
||||
return videoNode.getDuration();
|
||||
}
|
||||
},
|
||||
'paused':{
|
||||
get: function() {
|
||||
return videoNode.getPlayerState() !== 1;
|
||||
}
|
||||
},
|
||||
'error': {
|
||||
get: function() {
|
||||
return !!videoNode?.playerInfo?.videoData?.errorCode;
|
||||
}
|
||||
},
|
||||
'loading': {
|
||||
get: function() {
|
||||
return !videoNode?.playerInfo?.videoData?.isPlayable;
|
||||
; //todo
|
||||
}
|
||||
},
|
||||
'proportionLoaded': {
|
||||
get: function() {
|
||||
return videoNode?.playerInfo?.videoBytesLoaded >= 1; //todo
|
||||
}
|
||||
},
|
||||
'proportionPlayed': {
|
||||
get: function() {
|
||||
return videoNode.getCurrentTime() / videoNode.getDuration();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
handle.forward('onLoadStart', {type, ev}, rest);
|
||||
|
||||
@@ -92,20 +92,20 @@ const PlayerPanel = ({
|
||||
);
|
||||
|
||||
videoPlayer.current?.hideControls();
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
ev?.stopPropagation();
|
||||
ev?.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (!panelInfo.modal) {
|
||||
dispatch(PanelActions.popPanel());
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
ev?.stopPropagation();
|
||||
ev?.preventDefault();
|
||||
}
|
||||
|
||||
if (panelInfo.modal) {
|
||||
dispatch(PanelActions.popPanel());
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
ev?.stopPropagation();
|
||||
ev?.preventDefault();
|
||||
}
|
||||
},
|
||||
[dispatch, panelInfo]
|
||||
|
||||
Reference in New Issue
Block a user