OpenMediacenterMobileFlutter/lib/video_screen/videoscreen_desktop.dart

54 lines
1.3 KiB
Dart
Raw Normal View History

2022-04-15 16:15:44 +00:00
import 'dart:math';
import 'package:dart_vlc/dart_vlc.dart';
2022-04-15 16:15:44 +00:00
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class VideoScreenDesktop extends StatefulWidget {
const VideoScreenDesktop({Key? key, required this.url}) : super(key: key);
final String url;
2022-04-15 16:15:44 +00:00
@override
State<VideoScreenDesktop> createState() => _VideoScreenDesktopState();
2022-04-15 16:15:44 +00:00
}
class _VideoScreenDesktopState extends State<VideoScreenDesktop> {
Player _player = Player(id: Random().nextInt(0x7fffffff));
2022-04-15 18:19:09 +00:00
@override
Widget build(BuildContext context) {
return Video(
player: _player,
scale: 1.0, // default
showControls: true,
playlistLength: 1,
);
2022-04-15 16:15:44 +00:00
}
@override
void initState() {
super.initState();
final media2 = Media.network(widget.url);
_player.open(
media2,
autoStart: true, // default
);
RawKeyboard.instance.addListener((value) {
if (value.logicalKey == LogicalKeyboardKey.arrowRight) {
_player.seek(_player.position.position! + const Duration(seconds: 5));
} else if (value.logicalKey == LogicalKeyboardKey.arrowLeft) {
_player.seek(_player.position.position! + const Duration(seconds: -5));
}
});
2022-04-15 16:15:44 +00:00
}
@override
void dispose() {
super.dispose();
_player.dispose();
2022-04-15 16:15:44 +00:00
}
}