-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/plugins
#2922Labels
a: videoVideo playbackVideo playbackp: video_playerThe Video Player pluginThe Video Player pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.waiting for PR to land (fixed)A fix is in flightA fix is in flight
Description
I want to play a video as the background on the landing screen for our new app. While the video displays fine, I'm running into two issues which I think have the same root cause:
- As soon as the background video starts playing, the system music is stopped.
- Resuming the music (e.g. by swiping forward the control center and resuming, or telling Siri to resume the music) stops the video.
Steps to Reproduce
class Foobar extends StatefulWidget {
@override
_FoobarState createState() => _FoobarState();
}
class _FoobarState extends State<FoobarPage> {
final _controller = VideoPlayerController.asset('assets/foobar.mp4');
@override
void initState() {
super.initState();
_controller.initialize().then((_) async {
await _controller.setVolume(0);
await _controller.play();
await _controller.setLooping(true);
});
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Positioned(
top: 0,
left: 0,
right: 0,
bottom: 0,
child: VideoPlayer(_controller),
),
SafeArea(
child: Text('Content of the screen here...'),
),
],
),
);
}
}- Render that ☝️ widget in a
MaterialApp - Play some music on your iPhone
- Start the app
- Notice the music stopping and the video playing in the background
- Reveal the control center and resume the music
- Notice the video stopping in the background
Maybe a good solution could be a switch to the VideoPlayerController, e.g. Bool background, that when toggled disables audio and the system play/pause integration.
Logs
Analyzing foobar...
No issues found! (ran in 4.6s)
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.4 18E226, locale en-GB)
• Flutter version 1.2.1 at /Users/linus/coding/flutter
• Framework revision 8661d8aecd (7 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /usr/local/share/android-sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /usr/local/share/android-sdk
• ANDROID_SDK_ROOT = /usr/local/share/android-sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2, Build version 10E125
• ios-deploy 1.9.4
• CocoaPods version 1.6.1
[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 31.3.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] VS Code (version 1.32.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.25.0
[✓] Connected device (2 available)
• Linus Unnebäck’s iPhone • ~~redacted~~ • ios • iOS 12.2
• iPhone SE • ~~redacted~~ • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)
• No issues found!
CosmicPangolin, fferraris, uiboy, aytunch, obrunsmann and 2 more
Metadata
Metadata
Assignees
Labels
a: videoVideo playbackVideo playbackp: video_playerThe Video Player pluginThe Video Player pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.waiting for PR to land (fixed)A fix is in flightA fix is in flight