mirror of https://github.com/OpenVidu/openvidu.git
Bug fix: 'videoElementCreated' and 'videoPlaying' events NOT launched when no id is passed to initPublisher()
parent
3831138de3
commit
06e6f496ee
|
@ -229,8 +229,7 @@ export class LocalRecorder {
|
||||||
http.open("POST", endpoint, true);
|
http.open("POST", endpoint, true);
|
||||||
|
|
||||||
let sendable = new FormData();
|
let sendable = new FormData();
|
||||||
sendable.append("name", this.id);
|
sendable.append("file", this.blob, this.id + ".webm");
|
||||||
sendable.append("file", this.blob);
|
|
||||||
|
|
||||||
http.onreadystatechange = () => {
|
http.onreadystatechange = () => {
|
||||||
if (http.readyState === 4) {
|
if (http.readyState === 4) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ export class OpenViduInternal {
|
||||||
return this.localStream;
|
return this.localStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
cameraReady(localStream: Stream, parentId: string): HTMLVideoElement {
|
cameraReady(localStream: Stream, parentId: string) {
|
||||||
this.localStream = localStream;
|
this.localStream = localStream;
|
||||||
let videoElement = this.localStream.playOnlyVideo(parentId, null);
|
let videoElement = this.localStream.playOnlyVideo(parentId, null);
|
||||||
this.localStream.emitStreamReadyEvent();
|
this.localStream.emitStreamReadyEvent();
|
||||||
|
|
|
@ -146,8 +146,8 @@ export class Stream {
|
||||||
return this.video;
|
return this.video;
|
||||||
}
|
}
|
||||||
|
|
||||||
setVideoElement(video: HTMLVideoElement) {
|
setVideoElement(video) {
|
||||||
this.video = video;
|
if (!!video) this.video = video;
|
||||||
}
|
}
|
||||||
|
|
||||||
getParentId() {
|
getParentId() {
|
||||||
|
@ -267,45 +267,49 @@ export class Stream {
|
||||||
}
|
}
|
||||||
|
|
||||||
playOnlyVideo(parentElement, thumbnailId) {
|
playOnlyVideo(parentElement, thumbnailId) {
|
||||||
|
if (!!parentElement) {
|
||||||
|
|
||||||
this.video = document.createElement('video');
|
this.video = document.createElement('video');
|
||||||
|
|
||||||
this.video.id = (this.local ? 'local-' : 'remote-') + 'video-' + this.streamId;
|
this.video.id = (this.local ? 'local-' : 'remote-') + 'video-' + this.streamId;
|
||||||
this.video.autoplay = true;
|
this.video.autoplay = true;
|
||||||
this.video.controls = false;
|
this.video.controls = false;
|
||||||
this.ee.emitEvent('mediastream-updated');
|
this.ee.emitEvent('mediastream-updated');
|
||||||
|
|
||||||
if (this.local && !this.displayMyRemote()) {
|
if (this.local && !this.displayMyRemote()) {
|
||||||
this.video.muted = true;
|
this.video.muted = true;
|
||||||
this.video.oncanplay = () => {
|
this.video.onplaying = () => {
|
||||||
console.info("Local 'Stream' with id [" + this.streamId + "] video is now playing");
|
console.info("Local 'Stream' with id [" + this.streamId + "] video is now playing");
|
||||||
this.ee.emitEvent('video-is-playing', [{
|
this.ee.emitEvent('video-is-playing', [{
|
||||||
element: this.video
|
element: this.video
|
||||||
}]);
|
}]);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
this.video.title = this.streamId;
|
this.video.title = this.streamId;
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof parentElement === "string") {
|
|
||||||
this.parentId = parentElement;
|
|
||||||
|
|
||||||
let parentElementDom = document.getElementById(parentElement);
|
|
||||||
if (parentElementDom) {
|
|
||||||
this.video = parentElementDom.appendChild(this.video);
|
|
||||||
this.ee.emitEvent('video-element-created-by-stream', [{
|
|
||||||
element: this.video
|
|
||||||
}]);
|
|
||||||
this.isVideoELementCreated = true;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.parentId = parentElement.id;
|
if (typeof parentElement === "string") {
|
||||||
this.video = parentElement.appendChild(this.video);
|
this.parentId = parentElement;
|
||||||
|
|
||||||
|
let parentElementDom = document.getElementById(parentElement);
|
||||||
|
if (parentElementDom) {
|
||||||
|
this.video = parentElementDom.appendChild(this.video);
|
||||||
|
this.ee.emitEvent('video-element-created-by-stream', [{
|
||||||
|
element: this.video
|
||||||
|
}]);
|
||||||
|
this.isVideoELementCreated = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.parentId = parentElement.id;
|
||||||
|
this.video = parentElement.appendChild(this.video);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isReadyToPublish = true;
|
||||||
|
|
||||||
|
return this.video;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isReadyToPublish = true;
|
return null;
|
||||||
|
|
||||||
return this.video;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playThumbnail(thumbnailId) {
|
playThumbnail(thumbnailId) {
|
||||||
|
@ -602,22 +606,25 @@ export class Stream {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// let thumbnailId = this.video.thumb;
|
|
||||||
this.video.oncanplay = () => {
|
if (!!this.video) {
|
||||||
if (this.local && this.displayMyRemote()) {
|
// let thumbnailId = this.video.thumb;
|
||||||
console.info("Your own remote 'Stream' with id [" + this.streamId + "] video is now playing");
|
this.video.onplaying = () => {
|
||||||
this.ee.emitEvent('remote-video-is-playing', [{
|
if (this.local && this.displayMyRemote()) {
|
||||||
element: this.video
|
console.info("Your own remote 'Stream' with id [" + this.streamId + "] video is now playing");
|
||||||
}]);
|
this.ee.emitEvent('remote-video-is-playing', [{
|
||||||
} else if (!this.local && !this.displayMyRemote()) {
|
element: this.video
|
||||||
console.info("Remote 'Stream' with id [" + this.streamId + "] video is now playing");
|
}]);
|
||||||
this.ee.emitEvent('video-is-playing', [{
|
} else if (!this.local && !this.displayMyRemote()) {
|
||||||
element: this.video
|
console.info("Remote 'Stream' with id [" + this.streamId + "] video is now playing");
|
||||||
}]);
|
this.ee.emitEvent('video-is-playing', [{
|
||||||
}
|
element: this.video
|
||||||
//show(thumbnailId);
|
}]);
|
||||||
//this.hideSpinner(this.streamId);
|
}
|
||||||
};
|
//show(thumbnailId);
|
||||||
|
//this.hideSpinner(this.streamId);
|
||||||
|
};
|
||||||
|
}
|
||||||
this.room.emitEvent('stream-subscribed', [{
|
this.room.emitEvent('stream-subscribed', [{
|
||||||
stream: this
|
stream: this
|
||||||
}]);
|
}]);
|
||||||
|
|
Loading…
Reference in New Issue