video_player_extra 2.2.11+2 video_player_extra: ^2.2.11+2 copied to clipboard
A fork of flutter's video_player with extra ability to play 180 or 360 videos.
Video Player Exra plugin for Flutter #
A fork of flutter's video_player with extra ability to play 180 or 360 videos.
This plugin maintains same interface with the original package excepts:
- Add mediaFormat in VideoPlayerOption
- Add setMediaFormat in VideoPlayerController
- Add setCameraRotation in VideoPlayerController
Ideally, this plugin can be used as drop-in replacement for video_player package.
Camera control #
Just pass roll pitch yaw (in degree) to setCameraRotation method. Please see full example here
Example #
import 'package:video_player_extra/video_player.dart';
import 'package:flutter/material.dart';
void main() => runApp(VideoApp());
class VideoApp extends StatefulWidget {
@override
_VideoAppState createState() => _VideoAppState();
}
class _VideoAppState extends State<VideoApp> {
VideoPlayerController _controller;
@override
void initState() {
super.initState();
_controller = VideoPlayerController.network(
'https://videojs-vr.netlify.app/samples/eagle-360.mp4',
videoPlayerOptions: VideoPlayerOptions(
mixWithOthers: true,
mediaFormat: MediaFormat.VR2D360,
),
)..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Video Demo',
home: Scaffold(
body: Center(
child: _controller.value.isInitialized
? AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
)
: Container(),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
},
child: Icon(
_controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
),
),
),
);
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
}
More information #
Please read the original README.
License #
This package contains some code from Android AOSP project & Google VR SDK
Copyright 2017 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.