Unverified Commit 2352e31f authored by Sigurd Meldgaard's avatar Sigurd Meldgaard Committed by GitHub

Video demo is unsupported on simulator (#13333)

* Video demo is unsupported on simulator

Display a message stating this.

* Address review
parent b46d7904
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:connectivity/connectivity.dart'; import 'package:connectivity/connectivity.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart'; import 'package:video_player/video_player.dart';
import 'package:device_info/device_info.dart';
// TODO(sigurdm): These should not be stored here. // TODO(sigurdm): These should not be stored here.
const String butterflyUri = const String butterflyUri =
...@@ -348,6 +350,12 @@ class VideoDemo extends StatefulWidget { ...@@ -348,6 +350,12 @@ class VideoDemo extends StatefulWidget {
_VideoDemoState createState() => new _VideoDemoState(); _VideoDemoState createState() => new _VideoDemoState();
} }
final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
Future<bool> isIOSSimulator() async {
return Platform.isIOS && !(await deviceInfoPlugin.iosInfo).isPhysicalDevice;
}
class _VideoDemoState extends State<VideoDemo> class _VideoDemoState extends State<VideoDemo>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
final VideoPlayerController butterflyController = new VideoPlayerController( final VideoPlayerController butterflyController = new VideoPlayerController(
...@@ -359,6 +367,7 @@ class _VideoDemoState extends State<VideoDemo> ...@@ -359,6 +367,7 @@ class _VideoDemoState extends State<VideoDemo>
final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
final Completer<Null> connectedCompleter = new Completer<Null>(); final Completer<Null> connectedCompleter = new Completer<Null>();
bool isSupported = true;
@override @override
void initState() { void initState() {
...@@ -375,6 +384,9 @@ class _VideoDemoState extends State<VideoDemo> ...@@ -375,6 +384,9 @@ class _VideoDemoState extends State<VideoDemo>
initController(butterflyController); initController(butterflyController);
initController(beeController); initController(beeController);
isIOSSimulator().then((bool result) {
isSupported = !result;
});
} }
@override @override
...@@ -391,24 +403,30 @@ class _VideoDemoState extends State<VideoDemo> ...@@ -391,24 +403,30 @@ class _VideoDemoState extends State<VideoDemo>
appBar: new AppBar( appBar: new AppBar(
title: const Text('Videos'), title: const Text('Videos'),
), ),
body: new ConnectivityOverlay( body: (isSupported)
child: new ListView( ? new ConnectivityOverlay(
children: <Widget>[ child: new ListView(
new VideoCard( children: <Widget>[
title: 'Butterfly', new VideoCard(
subtitle: '… flutters by', title: 'Butterfly',
controller: butterflyController, subtitle: '… flutters by',
controller: butterflyController,
),
new VideoCard(
title: 'Bee',
subtitle: '… gently buzzing',
controller: beeController,
),
],
),
connectedCompleter: connectedCompleter,
scaffoldKey: scaffoldKey,
)
: const Center(
child: const Text(
'The video demo is not supported on the iOS Simulator.',
),
), ),
new VideoCard(
title: 'Bee',
subtitle: '… gently buzzing',
controller: beeController,
),
],
),
connectedCompleter: connectedCompleter,
scaffoldKey: scaffoldKey,
),
); );
} }
} }
...@@ -3,6 +3,7 @@ dependencies: ...@@ -3,6 +3,7 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
collection: 1.14.3 collection: 1.14.3
device_info: 0.0.5
intl: 0.15.2 intl: 0.15.2
connectivity: 0.1.0 connectivity: 0.1.0
string_scanner: 1.0.2 string_scanner: 1.0.2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment