video_360 0.0.9 video_360: ^0.0.9 copied to clipboard
Simple video 360 degree player (Android - Exoplayer, iOS - Swifty360Player)
import 'package:flutter/material.dart';
import 'package:video_360/video_360.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
const MyApp({
super.key,
});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
Video360Controller? controller;
String durationText = '';
String totalText = '';
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Video 360 Plugin example app'),
),
body: Stack(
children: [
Center(
child: SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: Video360View(
url: 'https://bitmovin-a.akamaihd.net/content/playhouse-vr/m3u8s/105560.m3u8',
onVideo360ViewCreated: _onVideo360ViewCreated,
onPlayInfo: (Video360PlayInfo info) {
setState(() {
durationText = info.duration.toString();
totalText = info.total.toString();
});
},
),
),
),
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
MaterialButton(
onPressed: () {
controller?.play();
},
color: Colors.grey[100],
child: const Text('Play'),
),
MaterialButton(
onPressed: () {
controller?.stop();
},
color: Colors.grey[100],
child: const Text('Stop'),
),
MaterialButton(
onPressed: () {
controller?.reset();
},
color: Colors.grey[100],
child: const Text('Reset'),
),
MaterialButton(
onPressed: () {
controller?.jumpTo(80000);
},
color: Colors.grey[100],
child: const Text('1:20'),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
MaterialButton(
onPressed: () {
controller?.seekTo(-2000);
},
color: Colors.grey[100],
child: const Text('<<'),
),
MaterialButton(
onPressed: () {
controller?.seekTo(2000);
},
color: Colors.grey[100],
child: const Text('>>'),
),
Flexible(
child: MaterialButton(
onPressed: () {},
color: Colors.grey[100],
child: Text('$durationText / $totalText'),
),
),
],
)
],
)
],
),
);
}
void _onVideo360ViewCreated(Video360Controller controller) {
this.controller = controller;
this.controller?.play();
}
}