2019-01-29 21:59:05 +02:00
|
|
|
part of '../../main.dart';
|
|
|
|
|
2019-02-20 16:39:57 +02:00
|
|
|
class CameraStreamView extends StatefulWidget {
|
2019-01-29 21:59:05 +02:00
|
|
|
|
2019-02-20 16:39:57 +02:00
|
|
|
CameraStreamView({Key key}) : super(key: key);
|
2019-01-29 21:59:05 +02:00
|
|
|
|
|
|
|
@override
|
2019-02-20 16:39:57 +02:00
|
|
|
_CameraStreamViewState createState() => _CameraStreamViewState();
|
2019-01-29 21:59:05 +02:00
|
|
|
}
|
|
|
|
|
2019-02-20 16:39:57 +02:00
|
|
|
class _CameraStreamViewState extends State<CameraStreamView> {
|
2019-01-29 21:59:05 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2019-01-31 01:04:13 +02:00
|
|
|
}
|
|
|
|
|
2019-02-20 16:39:57 +02:00
|
|
|
CameraEntity _entity;
|
|
|
|
bool started = false;
|
2019-06-21 21:01:53 +03:00
|
|
|
String streamUrl = "";
|
2019-01-29 21:59:05 +02:00
|
|
|
|
2019-06-21 14:29:56 +03:00
|
|
|
launchStream() {
|
2019-06-23 14:36:15 +03:00
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => WebviewScaffold(
|
|
|
|
url: "$streamUrl",
|
|
|
|
withZoom: true,
|
|
|
|
appBar: new AppBar(
|
|
|
|
leading: IconButton(
|
|
|
|
icon: Icon(Icons.close),
|
|
|
|
onPressed: () => Navigator.pop(context)
|
|
|
|
),
|
|
|
|
title: new Text("${_entity.displayName}"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
2019-06-21 21:01:53 +03:00
|
|
|
);
|
2019-02-20 13:57:25 +02:00
|
|
|
}
|
|
|
|
|
2019-01-29 21:59:05 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-02-20 16:39:57 +02:00
|
|
|
if (!started) {
|
|
|
|
_entity = EntityModel
|
|
|
|
.of(context)
|
|
|
|
.entityWrapper
|
|
|
|
.entity;
|
2019-06-21 14:29:56 +03:00
|
|
|
started = true;
|
2019-02-20 16:39:57 +02:00
|
|
|
}
|
2019-08-31 22:10:07 +03:00
|
|
|
streamUrl = '${ConnectionManager().httpWebHost}/api/camera_proxy_stream/${_entity
|
2019-06-21 21:01:53 +03:00
|
|
|
.entityId}?token=${_entity.attributes['access_token']}';
|
2019-06-21 14:29:56 +03:00
|
|
|
return Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
padding: const EdgeInsets.all(20.0),
|
2019-06-21 21:01:53 +03:00
|
|
|
child: IconButton(
|
|
|
|
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:monitor-screenshot"), color: Colors.amber),
|
2019-06-23 14:36:15 +03:00
|
|
|
iconSize: 50.0,
|
|
|
|
onPressed: () => launchStream(),
|
2019-02-20 17:55:56 +02:00
|
|
|
)
|
2019-06-21 14:29:56 +03:00
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
2019-01-29 21:59:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
}
|