Last active
February 17, 2020 17:25
-
-
Save mitchross/ad952529a9b906e7d4a150971a739fd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:typed_data'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_vlc_player/vlc_player.dart'; | |
import 'package:flutter_vlc_player/vlc_player_controller.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatefulWidget { | |
@override | |
_MyAppState createState() => new _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
Uint8List image; | |
GlobalKey imageKey; | |
VlcPlayer videoView; | |
VlcPlayerController _videoViewController; | |
VlcPlayerController _videoViewController2; | |
@override | |
void initState() { | |
imageKey = new GlobalKey(); | |
_videoViewController = new VlcPlayerController(); | |
_videoViewController2 = new VlcPlayerController(); | |
super.initState(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
home: new Scaffold( | |
appBar: new AppBar( | |
title: const Text('Plugin example app'), | |
), | |
floatingActionButton: FloatingActionButton( | |
child: Icon(Icons.camera), | |
onPressed: _createCameraImage, | |
), | |
body: Column( | |
children: <Widget>[ | |
new VlcPlayer( | |
defaultWidth: 640, | |
defaultHeight: 360, | |
url: "http://213.226.254.135:91/mjpg/video.mjpg", | |
controller: _videoViewController, | |
placeholder: Container( | |
height: 250.0, | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[CircularProgressIndicator()], | |
), | |
), | |
), | |
new VlcPlayer( | |
defaultWidth: 640, | |
defaultHeight: 360, | |
url: "http://213.226.254.135:91/mjpg/video.mjpg", | |
controller: _videoViewController2, | |
placeholder: Container( | |
height: 250.0, | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[CircularProgressIndicator()], | |
), | |
), | |
), | |
Expanded( | |
child: image == null | |
? Container() | |
: Container( | |
decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(image))), | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
void _createCameraImage() async { | |
Uint8List file = await _videoViewController.makeSnapshot(); | |
setState(() { | |
image = file; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment