Skip to content

Commit

Permalink
fix: Web call Platform API error
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed May 20, 2021
1 parent 6795c0b commit d760093
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 203 deletions.
4 changes: 2 additions & 2 deletions example/lib/examples/advanced/multi_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class _State extends State<MultiChannel> {
return Expanded(
child: Stack(
children: [
RtcLocalView.TextureView(
RtcLocalView.SurfaceView(
channelId: renderChannelId,
),
if (remoteUid != null)
Expand All @@ -248,7 +248,7 @@ class _State extends State<MultiChannel> {
(e) => Container(
width: 120,
height: 120,
child: RtcRemoteView.TextureView(
child: RtcRemoteView.SurfaceView(
uid: e,
channelId: renderChannelId,
),
Expand Down
16 changes: 11 additions & 5 deletions example/lib/examples/basic/join_channel_video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ class _State extends State<JoinChannelVideo> {
return Expanded(
child: Stack(
children: [
if (startPreview) RtcLocalView.TextureView(),
if (startPreview)
kIsWeb ? RtcLocalView.SurfaceView() : RtcLocalView.TextureView(),
Align(
alignment: Alignment.topLeft,
child: SingleChildScrollView(
Expand All @@ -185,10 +186,15 @@ class _State extends State<JoinChannelVideo> {
child: Container(
width: 120,
height: 120,
child: RtcRemoteView.TextureView(
uid: e,
channelId: channelId,
),
child: kIsWeb
? RtcRemoteView.SurfaceView(
uid: e,
channelId: channelId,
)
: RtcRemoteView.TextureView(
uid: e,
channelId: channelId,
),
),
),
)),
Expand Down
2 changes: 2 additions & 0 deletions lib/rtc_local_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class TextureView extends RtcTextureView {
mirrorMode = VideoMirrorMode.Disabled,
PlatformViewCreatedCallback? onPlatformViewCreated,
Set<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers,
useFlutterTexture = true,
}) : super(
key: key,
uid: 0,
Expand All @@ -49,5 +50,6 @@ class TextureView extends RtcTextureView {
mirrorMode: mirrorMode,
onPlatformViewCreated: onPlatformViewCreated,
gestureRecognizers: gestureRecognizers,
useFlutterTexture: useFlutterTexture,
);
}
2 changes: 2 additions & 0 deletions lib/rtc_remote_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class TextureView extends RtcTextureView {
mirrorMode = VideoMirrorMode.Auto,
PlatformViewCreatedCallback? onPlatformViewCreated,
Set<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers,
useFlutterTexture = true,
}) : assert(uid != 0),
super(
key: key,
Expand All @@ -52,5 +53,6 @@ class TextureView extends RtcTextureView {
mirrorMode: mirrorMode,
onPlatformViewCreated: onPlatformViewCreated,
gestureRecognizers: gestureRecognizers,
useFlutterTexture: useFlutterTexture,
);
}
6 changes: 4 additions & 2 deletions lib/src/events.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'dart:convert';
import 'dart:io';

import 'package:flutter/foundation.dart';

import 'classes.dart';
import 'enum_converter.dart';
import 'enums.dart';
Expand Down Expand Up @@ -1101,7 +1103,7 @@ class RtcEngineEventHandler {
// ignore: public_member_api_docs
void process(String methodName, dynamic data) {
List<dynamic> newData;
if (Platform.isWindows) {
if (!kIsWeb && Platform.isWindows) {
methodName = methodName.substring(2);
newData = List<dynamic>.from(
Map<String, dynamic>.from(jsonDecode(data as String)).values);
Expand Down Expand Up @@ -1840,7 +1842,7 @@ class RtcChannelEventHandler {
// ignore: public_member_api_docs
void process(String methodName, dynamic data) {
List<dynamic> newData;
if (Platform.isWindows) {
if (!kIsWeb && Platform.isWindows) {
methodName = methodName.substring(2);
newData = List<dynamic>.from(
Map<String, dynamic>.from(jsonDecode(data as String)).values);
Expand Down
Loading

0 comments on commit d760093

Please sign in to comment.