Closed mohammadabushalhoob closed 4 years ago
Yes,
AgoraRtcEngine.setChannelProfile(ChannelProfile.LiveBroadcasting)
before join channel,
and AgoraRtcEngine.setClientRole(ClientRole.Broadcaster)
for broadcaster and
AgoraRtcEngine.setClientRole(ClientRole.Audience)
for audience.
does it support screen sharing ?
Screen sharing is not supported for mobile SDK yet, it depends ReplayKit on iOS and Media Projection on Android.
So is it possible to pass external video in flutter? Like i have screen sharing code in flutter which provides live video frames how to pass this to agora? thank you
MediaStream _localStream;`
final _localRenderer = new RTCVideoRenderer()`;
await _localRenderer.initialize();
final Map<String, dynamic> mediaConstraints = {
"audio": true,
"video": true
};
var stream = await navigator.getDisplayMedia(mediaConstraints);
_localStream = stream;
_localRenderer.srcObject = _localStream;
so is it possible to pass this _localStream for broadcasting.
using the plugin flutter_ webrtc
Sorry but external media source is not supported.
Hello, thank you for this Flutter SDK Sample! I'm trying to make live broadcast work, here is the gist https://gist.github.com/alfonsodev/e7228253734ba11cd6cecc5cc50488f3 It is simplified to join directly to a broadcast, The Broadcaster seems to work (I can see the preview video) on the Audience side I only see black screen.
This is how I initialise the Audience side
Future<void> _initAgoraRtcEngine() async {
AgoraRtcEngine.create('xxxxxxxxxxxxxxxxxx');
AgoraRtcEngine.enableVideo();
AgoraRtcEngine.setChannelProfile(ChannelProfile.LiveBroadcasting);
AgoraRtcEngine.setClientRole(ClientRole.Audience);
AgoraRtcEngine.enableWebSdkInteroperability(true);
}
And then I render with
AgoraRtcEngine.createNativeView(1, (viewId) {
AgoraRtcEngine.setupRemoteVideo(viewId, VideoRenderMode.Fit, 1);
AgoraRtcEngine.joinChannel(null, 'flutter', null, 1);
})
And here is how I initialise the Host side,
Future<void> _initAgoraRtcEngine() async {
AgoraRtcEngine.create('xxxxxxxxxxxxxxxxxxxx');
AgoraRtcEngine.enableVideo();
AgoraRtcEngine.setChannelProfile(ChannelProfile.LiveBroadcasting);
AgoraRtcEngine.setClientRole(ClientRole.Broadcaster);
AgoraRtcEngine.enableWebSdkInteroperability(true);
}
and render
AgoraRtcEngine.createNativeView(0, (viweId) {
AgoraRtcEngine.setupLocalVideo(viweId, VideoRenderMode.Fit);
AgoraRtcEngine.startPreview();
AgoraRtcEngine.joinChannel(null, 'flutter', null, 0);
})
Any ideas why I'm not getting video in the Audience side ?
Thank you ❤️
Hi @alfonsodev
Audience has to setupRemoteVideo with uid of broadcaster, which you can get in the onUserJoined
callback.
AgoraRtcEngine.joinChannel(null, 'flutter', null, audienceUid);
AgoraRtcEngine.createNativeView(broadcasterUid, (viewId) {
AgoraRtcEngine.setupRemoteVideo(viewId, VideoRenderMode.Fit, broadcasterUid);
})
Thanks the quick reply,
but onUserJoined
, doesn't trigger on the Audience side
AgoraRtcEngine.setChannelProfile(ChannelProfile.LiveBroadcasting);
AgoraRtcEngine.setClientRole(ClientRole.Audience);
AgoraRtcEngine.onUserJoined = (int uid, int elapsed) {
_log("onUserJoined: uid: $uid elapsed: $elapsed");
};
AgoraRtcEngine.enableVideo();
_log('to join channel flutter with uid $_uid');
AgoraRtcEngine.leaveChannel();
AgoraRtcEngine.joinChannel(null, 'flutter', null, 0);
I found in the source code, onUserJoined
/// Live-broadcast profile: This callback notifies the app when the host joins the channel. If other hosts are already in the channel, the SDK also reports to the app on the existing hosts. Agora recommends having at most 17 hosts in a channel
But doesn't seem to trigger when the host joins, I'm testing on a real device, on debug mode.
update : I've added onError
and I don't say any error either
sorry it is working now, for some reason onUserJoined
wasn't triggering but it is working.
thanks!
Hello alfonsodev, in main.dart, I call the method Host.dart or Audiende.dart?
Hi @alfonsodev
Audience has to setupRemoteVideo with uid of broadcaster, which you can get in the
onUserJoined
callback.AgoraRtcEngine.joinChannel(null, 'flutter', null, audienceUid); AgoraRtcEngine.createNativeView(broadcasterUid, (viewId) { AgoraRtcEngine.setupRemoteVideo(viewId, VideoRenderMode.Fit, broadcasterUid); })
could you provide full example? i still getting black screen with as a audiance
I tried setting up mine the way @alfonsodev but when I try to broadcast I get a black screen. @PRWrl could you help?
@rlee1990 i'll close this one. please provide details in the new ticket you just opened.
Yes,
AgoraRtcEngine.setChannelProfile(ChannelProfile.LiveBroadcasting)
before join channel, andAgoraRtcEngine.setClientRole(ClientRole.Broadcaster)
for broadcaster andAgoraRtcEngine.setClientRole(ClientRole.Audience)
for audience.
do you have any example of that ? plz i need to make a live bradcasting module in my app
@khaliqdadmohmand is the sample within this repository not working for you?
i have issue in this line..
AgoraRtcEngine.createNativeView(0, (viweId){})
where it support only one parameter.. if i remove the broadcaster or audience ID which is here 0 in example.. the code works fine but audience cannot see the breadcaster.. please help me
sorry i don't quite get it. could you pls show me how you changed the code or share with me a sample project?
hi ,
can we use this example to puild Video Broadcasting .
thank you