capture MediaStream from a local video file in react naitve - react-native

The purpose is to play a local video on the host side and stream it on the participants' side. The video should pause and seek for everyone when the host does it.
For this, I want to capture a stream (of MediaStream type) of a local video file while it is playing and pass it into WebRTC.
Just like on the web we have a captureStream() method to capture stream from video or canvas, do we have anything similar in react-native? Or any other way to achieve the same goal?
I could not find a relative solution with the RTCView of react-native-webrtc or the react-native-video. Any type of solution or suggestion would be helpful.
Thank you in advance.

Related

How to stream microphone to speaker in react native

I need to stream microphone to speakers simultaneously in a react native project. I've tried the LiveAudioStream & MicStream packages, but I have no idea how can I directly play the microphone stream.
Can anyone suggest me the best way to do that?
Did you try this library react-native-audio-player-recorder library ? Maybe this let you do both things at same time

Can't send Media Stream of captureStream() through WebRTC

I create a WebRTC with simple peer. I need to capture stream from video element and send it to peers. I use vidEl.captureStream() to get Media Stream from video element and send it to other peer. It's working but only audio and video is blackscreen(not something is display).
[Testing] I create another video element on same origin of first video element and use captureStream() and test setObject with Media Stream captured and it's working.
How to send MediaStream from video.captureStream() to new peer through WebRTC and display video from remote peer.
Sorry for bad english.
https://webrtc.github.io/samples/src/content/capture/video-pc/
This sample does'nt work on chrome, edge but fire is worked. I don't know why.
There is currently an open bug in Chrome which breaks this:
https://bugs.chromium.org/p/chromium/issues/detail?id=1156408

WebRTC Audio Streaming without attaching to a html element

With reference to this tutorial. WebRTC - Voice Demo
The audio stream is attached to an <audio /> element for both Local and Remote audio.
I am a bit confused now. Aren't we suppose to connect the local audio to a Mic, instead of playing it?
Besides, for remote audio, is it possible for me to play the audio only without attaching it to an <audio /> element?
No, you need to create an audio element to play local audio as well.
The moment you call navigator.webkitGetUserMedia with constraints { video: false, audio: true }, you get your mic stream as a parameter on the callback. Then in order to play it, you need to attach it to an audio element, just like you would for remote audio, however, the remote audio stream will come from ontrack event instead.
But honestly, there is no reason for you to play your own local stream since the sound of your voice will overlap with the sound from the audio player. I guess they did it on the tutorial for demonstration purposes.
Btw, this tutorial you referred looks quite old, so if things don't work, that might be the reason why.

Webrtc stream local video file

How would one stream a local media file(video file) to peers?( i am using janus-gateway - videoroom plugin for this ).
For audio there is webAudio, but what about the video?
Thanks!
Update: Maybe someone has an example? Or a small code snippet? Maybe a link to some lib?
Render the local video on Canvas & create stream object from Canvas element.
And then you can add the stream to PeerConnection.
Then stream will be sent to remote peer(Janus/Browser/any server).
Demo: https://webrtc.github.io/samples/src/content/capture/canvas-pc/
Source: https://github.com/webrtc/samples/blob/gh-pages/src/content/capture/canvas-pc/js/main.js#L45

What's the recommended way to programmatically play an audio stream using iPhone SDK?

I have an mp3 on a remote server. Want to play it as a stream, using my own UI,and my own ViewController.
How would you recommend doing that?
I used the code from this page to make a streamer, and it worked well, and was easy to implement.
http://cocoawithlove.com/2009/06/revisiting-old-post-streaming-and.html