| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import 'package:flutter/material.dart';
- import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';
- /// Player builder, Inheritance of this class allows you to implement your own player
- typedef Widget IJKTextureBuilder(
- BuildContext context,
- IjkMediaController controller,
- VideoInfo info,
- );
- /// default IJKPlayer method
- Widget buildDefaultIjkPlayer(
- BuildContext context,
- IjkMediaController controller,
- VideoInfo info,
- ) {
- return DefaultIJKPlayerWrapper(
- controller: controller,
- info: info,
- );
- }
- /// Default IJKPlayer Wrapper
- ///
- /// This widget solves the aspect ratio problem in video direction.
- class DefaultIJKPlayerWrapper extends StatelessWidget {
- final IjkMediaController controller;
- final VideoInfo info;
- const DefaultIJKPlayerWrapper({
- Key key,
- this.controller,
- this.info,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- double ratio = info?.ratio ?? 1280 / 720;
- var id = controller.textureId;
- if (id == null) {
- return AspectRatio(
- aspectRatio: ratio,
- child: Container(
- color: Colors.black,
- ),
- );
- }
- Widget w = Container(
- color: Colors.black,
- child: Texture(
- textureId: id,
- ),
- );
- if (!controller.autoRotate) {
- return AspectRatio(
- aspectRatio: null,
- child: w,
- );
- }
- int degree = info?.degree ?? 0;
- if (ratio == 0) {
- ratio = 1280 / 720;
- }
- w = AspectRatio(
- aspectRatio: ratio,
- child: w,
- );
- if (degree != 0) {
- w = RotatedBox(
- quarterTurns: degree ~/ 90,
- child: w,
- );
- }
- return Container(
- child: w,
- alignment: Alignment.center,
- color: Colors.black,
- );
- }
- }
|