Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:supportsPictureInPicture="true"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package io.getstream.livestreaming_tutorial

import io.flutter.embedding.android.FlutterActivity
import io.getstream.video.flutter.stream_video_flutter.StreamFlutterActivity

class MainActivity: FlutterActivity()
class MainActivity: StreamFlutterActivity()
48 changes: 20 additions & 28 deletions livestreaming_tutorial/lib/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class _HomeScreenState extends State<HomeScreen> with WidgetsBindingObserver {

RtcMediaDeviceNotifier.instance.handleCallInterruptionCallbacks(
onInterruptionStart: () {
rtc.Helper.pauseAudioPlayout();
RtcMediaDeviceNotifier.instance.pauseAudioPlayout();
},
onInterruptionEnd: () {
rtc.Helper.resumeAudioPlayout();
RtcMediaDeviceNotifier.instance.resumeAudioPlayout();
},
androidInterruptionSource: rtc.AndroidInterruptionSource.telephonyOnly,
);
Expand All @@ -72,10 +72,13 @@ class _HomeScreenState extends State<HomeScreen> with WidgetsBindingObserver {
void didChangeAppLifecycleState(AppLifecycleState state) {
// Handle pausing/resuming audio playout on app lifecycle changes
if (state == AppLifecycleState.paused) {
rtc.Helper.pauseAudioPlayout();
RtcMediaDeviceNotifier.instance.pauseAudioPlayout();
} else if (state == AppLifecycleState.resumed) {
rtc.Helper.resumeAudioPlayout();
rtc.Helper.regainAndroidAudioFocus();
RtcMediaDeviceNotifier.instance.resumeAudioPlayout();

if (CurrentPlatform.isAndroid) {
RtcMediaDeviceNotifier.instance.regainAndroidAudioFocus();
}
}
}

Expand Down Expand Up @@ -235,29 +238,7 @@ class _HomeScreenState extends State<HomeScreen> with WidgetsBindingObserver {
final result = await call.getOrCreate(); // Call object is created

if (result.isSuccess) {
// Set default behaviour for a livestream viewer
final connectOptions = CallConnectOptions(
camera: TrackOption.disabled(),
microphone: TrackOption.disabled(),
);

// Our local app user can join and receive events
final joinResult = await call.join(connectOptions: connectOptions);
setState(() => viewLoadingText = null);

if (joinResult case Failure failure) {
debugPrint('Not able to join the call: ${failure.error}');
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content:
Text('Not able to join the call: ${failure.error.message}'),
),
);
}
return;
}

if (!mounted) return;

// Viewers see the simple player
Expand All @@ -274,7 +255,18 @@ class _HomeScreenState extends State<HomeScreen> with WidgetsBindingObserver {
},
),
),
body: LivestreamPlayer(call: call),
body: LivestreamPlayer(
call: call,
joinBehaviour: LivestreamJoinBehaviour.autoJoinAsap,
connectOptions: CallConnectOptions(
camera: TrackOption.disabled(),
microphone: TrackOption.disabled(),
),
pictureInPictureConfiguration:
const PictureInPictureConfiguration(
enablePictureInPicture: true,
),
),
),
),
);
Expand Down
4 changes: 2 additions & 2 deletions ringing_tutorial/lib/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class _HomeScreenState extends State<HomeScreen> {
_tryConsumingIncomingCallFromTerminatedState();

_observeFcmMessages();
_observeCallKitEvents();
_observeRingingEvents();
}

void _tryConsumingIncomingCallFromTerminatedState() {
Expand Down Expand Up @@ -117,7 +117,7 @@ class _HomeScreenState extends State<HomeScreen> {
);
}

void _observeCallKitEvents() {
void _observeRingingEvents() {
final streamVideo = StreamVideo.instance;

subscriptions.add(
Expand Down