VideoUIKit-Flutter icon indicating copy to clipboard operation
VideoUIKit-Flutter copied to clipboard

AgoraUser

Open kyawthet-wam opened this issue 1 year ago • 9 comments

https://github.com/AgoraIO-Community/VideoUIKit-Flutter/issues/137#issue-1718845438 having the same issue when I pinned the remote user.

kyawthet-wam avatar Jun 08 '23 14:06 kyawthet-wam

Can you try this with the new 1.3.4 version?

tadaspetra avatar Jun 19 '23 20:06 tadaspetra

Can you try this with the new 1.3.4 version?

Screenshot_1687249316

This is with 1.3.4 version.

kyawthet-wam avatar Jun 20 '23 08:06 kyawthet-wam

@kyawthet-wam Can you share the code, stack trace, and what steps you took to reproduce this issue?

tadaspetra avatar Jun 20 '23 13:06 tadaspetra

@RoutePage() class VideoCallPage extends ConsumerStatefulWidget { const VideoCallPage({ Key? key, required this.token, required this.channelName, required this.gpId, required this.isGroup, required this.isCaller, }) : super(key: key); final String token; final String channelName; final int gpId; final bool isGroup; final bool isCaller; @override VideoCallPageState createState() => VideoCallPageState(); }

class VideoCallPageState extends ConsumerState<VideoCallPage> { late String chName; late String token; late AgoraClient client; int initialCountDown = 30; Timer? _timer; int waitingTime = 0; var stopwatch = Stopwatch();

void initAgora() async { await client.initialize(); }

@override void dispose() { client.engine.leaveChannel(); client.engine.release(); _timer!.cancel(); super.dispose(); }

@override void initState() { super.initState(); chName = widget.channelName; client = AgoraClient( agoraEventHandlers: AgoraRtcEventHandlers( onUserJoined: (connection, remoteUid, elapsed) { SystemSound.play(SystemSoundType.click); HapticFeedback.lightImpact(); stopwatch.start(); }, ), agoraConnectionData: AgoraConnectionData( appId: appId, rtmUid: widget.gpId.toString(), channelName: widget.channelName, username: 'user', tempToken: widget.token, uid: SharedPrefs.getInt('user_id')!, ), );

initAgora();

waitingTime = initialCountDown;

_timer = Timer.periodic(
  const Duration(seconds: 1),
  (_) {
    waitingTime--;
    if (waitingTime == 0 && client.users.isEmpty) {
      EasyLoading.showToast('Call End');
      Navigator.pop(context, {"duration": 0});
    }
  },
);

}

@override Widget build(BuildContext context) { final chatNotifier = ref.read(chatMessageListProvider( Param(p1: widget.gpId, p2: widget.isGroup ? 1 : 0), ).notifier);

void endCall() {
  String text =
      '📹  Video call (${FormatDuration.format(stopwatch.elapsed)})';

  chatNotifier
      .sentGroupMessage(
    groupId: widget.gpId,
    fileList: [],
    text: text,
    fileNameList: [],
  )
      .then((value) {
    value.maybeWhen(
      error: (l) => l.maybeWhen(
        unexpectedError: () => EasyLoading.showToast(
            AppLocalizations.of(context)!.something_went_wrong),
        serverError: (message) => EasyLoading.showToast(message!),
        orElse: () {},
      ),
      orElse: () {
        Navigator.pop(context);
      },
    );
  });
}

void cancelCall() {
  chatNotifier.cancelCall().then((value) {
    value.maybeWhen(
      error: (l) => l.maybeWhen(
        unexpectedError: () => EasyLoading.showToast(
            AppLocalizations.of(context)!.something_went_wrong),
        serverError: (message) => EasyLoading.showToast(message!),
        orElse: () {},
      ),
      saved: () {
        SharedPrefs.setBool('cancel', true);

        Navigator.pop(context);
      },
      orElse: () {},
    );
  });
}

return WillPopScope(
  onWillPop: () {
    if (client.users.isEmpty &&
        stopwatch.elapsed.inSeconds == 0 &&
        widget.isCaller) {
      cancelCall();
    } else if (client.users.isEmpty) {
      endCall();
    } else {
      Navigator.pop(context);
    }
    return Future.value(true);
  },
  child: SafeArea(
    child: Scaffold(
      backgroundColor: Colors.black,
      body: Stack(
        children: [
          AgoraVideoViewer(
            client: client,
            showAVState: true,
            showNumberOfUsers: true,
            layoutType: Layout.floating,
            enableHostControls: true,
          ),
          AgoraVideoButtons(
            client: client,
            disconnectButtonChild: RawMaterialButton(
              onPressed: () {
                if (client.users.isEmpty &&
                    stopwatch.elapsed.inSeconds == 0 &&
                    widget.isCaller) {
                  cancelCall();
                } else if (client.users.isEmpty) {
                  endCall();
                } else {
                  Navigator.pop(context);
                }
              },
              shape: const CircleBorder(),
              elevation: 2.0,
              fillColor: Colors.redAccent,
              padding: const EdgeInsets.all(15.0),
              child: const Icon(
                Icons.call_end,
                color: Colors.white,
                size: 35.0,
              ),
            ),
            autoHideButtons: true,
          ),
        ],
      ),
    ),
  ),
);

} }

kyawthet-wam avatar Jun 20 '23 13:06 kyawthet-wam

Sorry for my bad code. Thanks for your help.

kyawthet-wam avatar Jun 20 '23 13:06 kyawthet-wam

image

line no 329

kyawthet-wam avatar Jun 20 '23 15:06 kyawthet-wam

@kyawthet-wam This issue should have been fixed with v1.3.4

Can you please try a flutter clean and then installing the dependencies.

Meherdeep avatar Jun 20 '23 19:06 Meherdeep

@Meherdeep Yes. But it didn't work.

kyawthet-wam avatar Jun 21 '23 02:06 kyawthet-wam

@kyawthet-wam Can you please try the example code and share the SDK logs

Meherdeep avatar Jun 21 '23 11:06 Meherdeep