Skip to content

Commit 763e147

Browse files
authoredDec 5, 2024··
Merge pull request #71 from ant-media/pause_feature_for_play
Pause,fullscreen feature for play example
2 parents 44cafcf + 3167a7c commit 763e147

File tree

1 file changed

+56
-14
lines changed

1 file changed

+56
-14
lines changed
 

‎example/SampleProject/lib/play.dart

+56-14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class _PlayState extends State<Play> {
2727
final RTCVideoRenderer _remoteRenderer = RTCVideoRenderer();
2828
List<String> abrList = ['Automatic'];
2929
bool _inCalling = false;
30+
bool _isPaused = false;
31+
bool _isFullScreen = false;
3032

3133
_PlayState();
3234

@@ -85,7 +87,8 @@ class _PlayState extends State<Play> {
8587
_localRenderer.srcObject = null;
8688
_remoteRenderer.srcObject = null;
8789
_inCalling = false;
88-
Navigator.pop(context);
90+
_isPaused ? _isPaused : Navigator.pop(context);
91+
// Navigator.pop(context);
8992
});
9093
break;
9194
case HelperState.ConnectionOpen:
@@ -172,8 +175,8 @@ class _PlayState extends State<Play> {
172175
heroTag: "btn2",
173176
onPressed: _hangUp,
174177
tooltip: 'Hangup',
175-
child: const Icon(Icons.call_end),
176178
backgroundColor: Colors.pink,
179+
child: const Icon(Icons.call_end),
177180
),
178181
DropdownButton<String>(
179182
items: abrList.map((String value) {
@@ -190,21 +193,60 @@ class _PlayState extends State<Play> {
190193
)
191194
]))
192195
: null,
193-
body: OrientationBuilder(builder: (context, orientation) {
194-
return Stack(children: <Widget>[
195-
Positioned(
196-
left: 0.0,
197-
right: 0.0,
198-
top: 0.0,
199-
bottom: 0.0,
200-
child: Container(
196+
body: OrientationBuilder(
197+
builder: (context, orientation) {
198+
return Stack(
199+
children: <Widget>[
200+
_isFullScreen ? Container(
201+
margin: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
202+
width: MediaQuery.of(context).size.width,
203+
height: MediaQuery.of(context).size.height,
204+
decoration: const BoxDecoration(color: Colors.black54),
205+
child: RTCVideoView(_remoteRenderer,objectFit: orientation == Orientation.portrait ? RTCVideoViewObjectFit.RTCVideoViewObjectFitContain : RTCVideoViewObjectFit.RTCVideoViewObjectFitCover ),
206+
) : Container(
201207
margin: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
202208
width: MediaQuery.of(context).size.width,
203209
height: MediaQuery.of(context).size.height,
204-
child: RTCVideoView(_remoteRenderer),
205210
decoration: const BoxDecoration(color: Colors.black54),
206-
)),
207-
]);
208-
}));
211+
child: RTCVideoView(_remoteRenderer),
212+
),
213+
_isPaused
214+
? Center(
215+
child: FloatingActionButton(
216+
heroTag: "btn3",
217+
onPressed: () {
218+
setState(() {
219+
_isPaused = false;
220+
});
221+
_connect();
222+
},
223+
tooltip: 'Play',
224+
backgroundColor: Colors.grey.withOpacity(0.6),
225+
child: const Icon(Icons.play_arrow),
226+
),
227+
)
228+
: GestureDetector(
229+
onTap: () {
230+
setState(() {
231+
_isPaused = true;
232+
});
233+
_hangUp();
234+
},
235+
child: Container(
236+
color: Colors.transparent, // Makes the entire screen tappable
237+
width: MediaQuery.of(context).size.width,
238+
height: MediaQuery.of(context).size.height,
239+
alignment: Alignment.center,
240+
child: const Icon(
241+
Icons.pause,
242+
color: Colors.transparent, // Keeps the icon invisible
243+
),
244+
),
245+
),
246+
],
247+
);
248+
},
249+
)
250+
);
209251
}
210252
}

0 commit comments

Comments
 (0)
Please sign in to comment.