Pause streaming video and file transfer

hi, in one of my projects of openvidu i have a requirement of pausing the video and sharing the files between 2 users who are on call connected. is that possible to achieve this both things? as I referred in google I didn’t found any solution for the file transfer but by reading some blog i came to know that. it’s possible to pause the video. if my assumption is correct please let me know the code of pausing the video in the stream.

thank you. waiting for response.

To pause the video transmission just use Publisher.publishAudio and Publisher.publisVideo in your frontend: https://docs.openvidu.io/en/stable/api/openvidu-browser/classes/publisher.html#publishaudio

hi @pabloFuente pabloFuente thank you very much for your quick response. i will try it and get back.

hi. by your method i successfully unpublished the video but after clicking on same button i need to again publish that. it mean i’m looking for something toggle type when i click once video stop publishing and when i click back again start publishing. right unpublish is done but when i try to republish it getting error as

Cannot read property ‘removeChild’ of null
at StreamManager.ts:422
at Array.forEach ()
at Publisher.StreamManager.removeAllVideos (StreamManager.ts:415)
at StreamEvent.callDefaultBehavior (StreamEvent.ts:97)
at Session.unpublish (Session.ts:453)
at HTMLButtonElement.document.getElementById.onclick (app.js:140)

jsonrpcclient.js:173 ERROR:Participant ‘con_ISu7crzxTT’ is not streaming media. Code: 105 in Request: method:unpublishVideo params:{} request:undefined

here i’m attaching screen shot for more clearance.

here is my code of publish and unpublish

html part
< button class=“btn rounded-circle bg-dark playing” id=“pause” type=“pause”>
< div class=“callicons”>
< /button>

js part

document.addEventListener(“DOMContentLoaded”, function(event) {
document.getElementById(‘pause’).onclick = function() {
var className = ’ ’ + pause.className + ’ ‘;
if ( ~className.indexOf(’ playing ‘) ) {
this.className = className.replace(’ active ', ’ ‘);
session.unpublish(publisher);
} else {
this.className += ’ active’;
session.publish(publisher);
}
}
});

You are not using the method I told you. You are using “Session.publish” and “Session.unpublish”, not “Publisher.publishAudio(bool)” and “Publisher.publishVideo(bool)”.

Besides, you are calling more than once to “Session.connect”. Check your JavaScript code.

hi pabloFuente thank you for guiding me correct way. issue has got solved thank you for help and you guys are going so rock with openvidu. i’m using it since 8 months most of all found successfull replay with you guys only thank you very much for providing such a good thing.

2 Likes