TT#70157 Fix duplicate media creation issue

Change-Id: I5e4728fda8d1ff260a1183ef0c8eeeccc17ea11b
changes/07/35107/2
Hans-Peter Herzog 6 years ago
parent 151dc02f36
commit 81f46b5216

@ -66,6 +66,13 @@
QIcon QIcon
}, },
methods: { methods: {
reset() {
if (this.$refs.media) {
this.$refs.media.pause();
this.$refs.media.srcObject = null;
this.$refs.media.load();
}
},
assignStream(stream) { assignStream(stream) {
if(stream !== null && stream !== undefined) { if(stream !== null && stream !== undefined) {
this.loading = true; this.loading = true;

@ -99,7 +99,8 @@
<script> <script>
import { import {
mapGetters mapGetters,
mapActions
} from 'vuex' } from 'vuex'
import CscConferenceJoin from '../pages/Conference/CscConferenceJoin' import CscConferenceJoin from '../pages/Conference/CscConferenceJoin'
import CscConferenceJoined from '../pages/Conference/CscConferenceJoined' import CscConferenceJoined from '../pages/Conference/CscConferenceJoined'
@ -171,6 +172,9 @@
} }
}, },
methods: { methods: {
...mapActions('conference', [
'leave'
]),
close() { close() {
if(!this.isJoined) { if(!this.isJoined) {
this.$router.push({path: '/user/home'}); this.$router.push({path: '/user/home'});
@ -198,13 +202,7 @@
}, },
async join(conferenceId) { async join(conferenceId) {
if(this.hasConferenceId) { if(this.hasConferenceId) {
await this.$store.dispatch('conference/enableMicrophone'); await this.$store.dispatch('conference/join', conferenceId);
this.$store.dispatch('conference/join', conferenceId);
}
},
leave() {
if(this.isJoined) {
this.$store.dispatch('conference/leave');
} }
} }
}, },
@ -213,6 +211,11 @@
if(!value) { if(!value) {
this.$store.commit('conference/disposeLocalMedia'); this.$store.commit('conference/disposeLocalMedia');
} }
},
localMediaStream(stream) {
if (this.$refs.localMedia && (stream === null || stream === undefined)) {
this.$refs.localMedia.reset();
}
} }
} }
} }

@ -51,6 +51,9 @@
if (this.$refs.cscMedia && this.remoteMediaStreams[this.remoteParticipant.id] === this.remoteParticipant.id) { if (this.$refs.cscMedia && this.remoteMediaStreams[this.remoteParticipant.id] === this.remoteParticipant.id) {
this.$refs.cscMedia.assignStream(this.remoteMediaStream(this.remoteParticipant.id)); this.$refs.cscMedia.assignStream(this.remoteMediaStream(this.remoteParticipant.id));
} }
else if (this.$refs.cscMedia) {
this.$refs.cscMedia.reset();
}
} }
}, },
watch: { watch: {

@ -43,32 +43,20 @@ export class ConferencePlugin {
return this.rtcEngine.getConferenceNetwork(); return this.rtcEngine.getConferenceNetwork();
} }
joinConference(options) { async joinConference(options) {
return new Promise((resolve, reject)=>{
options.localMediaStream = this.getLocalMediaStream(); options.localMediaStream = this.getLocalMediaStream();
this.getNetwork().joinConference(options).then((conference)=>{ this.conference = await this.getNetwork().joinConference(options);
this.conference = conference; return this.conference;
resolve(conference);
}).catch((err)=>{
reject(err);
});
});
} }
changeConferenceMedia() { async changeConferenceMedia() {
return new Promise((resolve, reject)=>{ await this.getNetwork().changeConferenceMedia({
this.getNetwork().changeConferenceMedia({
localMediaStream: this.getLocalMediaStream() localMediaStream: this.getLocalMediaStream()
}).then(()=>{
resolve();
}).catch((err)=>{
reject(err);
});
}); });
} }
leaveConference() { async leaveConference() {
return this.getNetwork().leaveConference(); await this.getNetwork().leaveConference();
} }
onLeft(listener) { onLeft(listener) {
@ -137,6 +125,7 @@ export class ConferencePlugin {
if(this.hasLocalMediaStream()) { if(this.hasLocalMediaStream()) {
this.getLocalMediaStream().stop(); this.getLocalMediaStream().stop();
} }
this.localMediaStream = null;
} }
getLocalMediaStreamNative() { getLocalMediaStreamNative() {

@ -232,9 +232,6 @@ export default {
let localMediaStream; let localMediaStream;
return media.build().then(($localMediaStream) => { return media.build().then(($localMediaStream) => {
localMediaStream = $localMediaStream; localMediaStream = $localMediaStream;
localMediaStream.onVideoEnded(() => {
context.dispatch('createLocalMedia', MediaTypes.mic);
});
Vue.$conference.setLocalMediaStream(localMediaStream); Vue.$conference.setLocalMediaStream(localMediaStream);
switch (type) { switch (type) {
default: default:
@ -371,28 +368,33 @@ export default {
context.dispatch('disableScreen'); context.dispatch('disableScreen');
} }
}, },
join(context, conferenceId) { async join(context, conferenceId) {
if (context.getters.hasLocalMediaStream) { try {
if (!Vue.$conference.hasLocalMediaStream()) {
await context.dispatch('enableMicrophone');
}
context.commit('joinRequesting'); context.commit('joinRequesting');
Vue.$conference.joinConference({ await Vue.$conference.joinConference({
conferenceName: conferenceId, conferenceName: conferenceId,
displayName: context.getters.username displayName: context.getters.username
}).then(() => { });
context.commit('joinSucceeded'); context.commit('joinSucceeded');
}).catch((err) => { }
catch (err) {
context.commit('joinFailed', err.message); context.commit('joinFailed', err.message);
});
} }
}, },
leave(context) { async leave(context) {
if (context.getters.isJoined) { if (context.getters.isJoined) {
try {
context.commit('leaveRequesting'); context.commit('leaveRequesting');
Vue.$conference.leaveConference().then(() => { await Vue.$conference.leaveConference();
context.commit('leaveSucceeded'); context.commit('leaveSucceeded');
context.commit('disposeLocalMedia'); context.commit('disposeLocalMedia');
}).catch((err) => { }
catch (err) {
context.commit('leaveFailed', err.message); context.commit('leaveFailed', err.message);
}); }
} }
} }
} }

Loading…
Cancel
Save