How can I show the broadcasting event to the audience
I'm creating an event where I add the broadcast part now I want to make a page for the audience How can I see the event without uid or is there another way to join the broadcasting without uid
Through my code I can hear sound but video doesn't show on screen
import 'dart:async';
import 'package:agora_rtc_engine/rtc_engine.dart';
import 'package:agora_rtc_engine/rtc_local_view.dart' as RtcLocalView;
import 'package:agora_rtc_engine/rtc_remote_view.dart' as RtcRemoteView;
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:user/settings/agora.dart';
import 'package:user/theme/colors.dart';
import '../utils/setting.dart';
class UserLiveStreaming extends StatefulWidget {
/// non-modifiable channel name of the page
final String channel;
final String eventId;
/// non-modifiable client role of the page
final ClientRole role;
final String token;
final String name;
/// Creates a call page with given channel name.
const UserLiveStreaming(
{Key key, this.channel, this.role, this.token, this.eventId, this.name})
: super(key: key);
@override
_UserLiveStreamingState createState() => _UserLiveStreamingState();
}
class _UserLiveStreamingState extends State<UserLiveStreaming> {
final _users = <int>[];
final _infoStrings = <String>[];
bool muted = false;
RtcEngine _engine;
TextEditingController msg = TextEditingController();
int _remoteUid;
@override
void dispose() {
// clear users
_users.clear();
// destroy sdk
_engine.leaveChannel();
_engine.destroy();
super.dispose();
}
clear() {
_users.clear();
// destroy sdk
_engine.leaveChannel();
_engine.destroy();
}
@override
void initState() {
super.initState();
// initialize agora sdk
initAgora();
}
Future<void> initAgora() async {
// retrieve permissions
print('after engine');
//create the engine
_engine = await RtcEngine.create(appId);
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
await _engine.setClientRole(ClientRole.Audience);
print('form engine');
_engine.setEventHandler(
RtcEngineEventHandler(
joinChannelSuccess: (String channel, int uid, int elapsed) {
print("local user $uid joined");
},
userJoined: (int uid, int elapsed) {
print("remote user $uid joined");
setState(() {
_remoteUid = uid;
});
},
userOffline: (int uid, UserOfflineReason) {
clear();
Get.back();
},
),
);
await _engine.joinChannel(widget.token, widget.channel, null, 0);
}
Widget _remoteVideo() {
if (_remoteUid != null) {
return RtcRemoteView.SurfaceView(
uid: _remoteUid,
renderMode: VideoRenderMode.Fit,
);
} else {
return Center(
child: Text(
'Calling...',
textAlign: TextAlign.center,
),
);
}
}
@override
Widget build(BuildContext context) {
CollectionReference chats = FirebaseFirestore.instance.collection('chat');
return Scaffold(
body: Stack(
children: <Widget>[
Center(
child: _remoteVideo(),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.only(left: 20, right: 20),
color: Colors.white,
// height: 70,
width: MediaQuery.of(context).size.width - 40,
child: Row(
children: [
Expanded(
child: TextField(
// expands: true,
controller: msg,
maxLines: 8,
minLines: 1,
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Enter text message',
))),
Container(
width: 50,
child: IconButton(
icon: Icon(Icons.send),
onPressed: () {
chats.add({
'event_id': widget.eventId,
'message': msg.text,
'time': DateTime.now(),
'name': widget.name,
});
Get.snackbar(
'Message',
'Message sent',
colorText: Colors.white,
snackPosition: SnackPosition.BOTTOM,
backgroundColor: primary,
margin: EdgeInsets.all(10),
duration: Duration(seconds: 2),
);
msg.clear();
}),
),
],
),
)),
],
),
floatingActionButtonLocation: FloatingActionButtonLocation.startTop,
floatingActionButton: FloatingActionButton(
onPressed: () {
print('remote uid $_remoteUid');
Get.defaultDialog(
title: "WARNING!!!",
content: Text("Are you sure you want to quit?"),
onConfirm: () {
clear();
Get.back();
},
onCancel: () => Get.back(),
);
},
child: Icon(Icons.close),
),
);
}
}
Sorry for the late reply, the best way is using your server.
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens, logs and the output. All system setups can be slightly different so it's always better to open new issues and reference the related ones. Thanks for your contribution.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please raise a new issue.