DCINetworkApp/lib/main.dart
2025-06-10 00:38:11 -05:00

159 lines
4.4 KiB
Dart

import 'dart:developer';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:video_player_win/video_player_win.dart';
void main() {
//MediaKit.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late WinVideoPlayerController _controller;
@override
void initState() {
super.initState();
_controller = WinVideoPlayerController.file(File("C:\\Users\\kacar\\Desktop\\Data Projects\\DCIPlayer\\dci_player_app\\assets\\Bluecoats_2015_Kinetic_Noise.mp4"));
_controller.initialize().then((value) {
if (_controller.value.isInitialized) {
_controller.play();
setState(() {});
} else {
log("error");
}
});
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('DCI Player'),
),
body: Stack(children: [
WinVideoPlayer(_controller),
Positioned(
bottom: 0,
child: Column(children: [
ValueListenableBuilder(
valueListenable: _controller,
builder: ((context, value, child) {
int minute = _controller.value.position.inMinutes;
int second = _controller.value.position.inSeconds % 60;
return Text("$minute:$second");
}),
),
ElevatedButton(onPressed: () => _controller.play(), child: const Text("Play")),
ElevatedButton(onPressed: () => _controller.pause(), child: const Text("Pause")),
ElevatedButton(onPressed: () => _controller.seekTo(Duration(milliseconds: _controller.value.position.inMilliseconds + 10*1000)), child: const Text("Forward")),
]),
),
]),
),
);
}
}
// class VideoPlayerScreeen extends StatefulWidget {
// const VideoPlayerScreeen({super.key});
//
// @override
// State<VideoPlayerScreeen> createState() => _VideoPlayerScreeenState();
// }
//
// class _VideoPlayerScreeenState extends State<VideoPlayerScreeen> {
// late final player = Player();
// late final controller = VideoController(player);
//
// @override
// void initState() {
// super.initState();
// player.open(Media('assets/Bluecoats_2015_Kinetic_Noise.mp4'));
// }
//
// @override
// void dispose() {
// player.dispose();
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(
// title: const Text('DCI Player'),
// ),
// body: AspectRatio(
// aspectRatio: 16 / 9,
// child: BetterPlayer.file("assets/Bluecoats_2015_Kinetic_Noise.mp4",
// betterPlayerConfiguration: BetterPlayerConfiguration(
// aspectRatio: 16 / 9,
// autoPlay: true
// )
// ),
// )
// );
// }
// }
//
// class MyHomePage extends StatefulWidget {
// const MyHomePage({super.key, required this.title});
//
// final String title;
//
// @override
// State<MyHomePage> createState() => _MyHomePageState();
// }
//
// class _MyHomePageState extends State<MyHomePage> {
// int _counter = 0;
//
// void _incrementCounter() {
// setState(() {
// _counter++;
// });
// }
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(
// backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// title: Text(widget.title),
// ),
// body: Center(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// const Text('You have pushed the button this many times:'),
// Text(
// '$_counter',
// style: Theme.of(context).textTheme.headlineMedium,
// ),
// ],
// ),
// ),
// floatingActionButton: FloatingActionButton(
// onPressed: _incrementCounter,
// tooltip: 'Increment',
// child: const Icon(Icons.add),
// ), // This trailing comma makes auto-formatting nicer for build methods.
// );
// }
// }