Reproductor chewi integrado, wip tags, y diseño
This commit is contained in:
75
assets/referencia/video_player_caro.text
Normal file
75
assets/referencia/video_player_caro.text
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:appinio_video_player/appinio_video_player.dart';
|
||||
|
||||
class VideoScreenNew extends StatefulWidget {
|
||||
final dynamic videoUrl;
|
||||
const VideoScreenNew({Key? key, required this.videoUrl}) : super(key: key);
|
||||
|
||||
@override
|
||||
_VideoScreenNewState createState() => _VideoScreenNewState();
|
||||
}
|
||||
|
||||
class _VideoScreenNewState extends State<VideoScreenNew> {
|
||||
late VideoPlayerController _videoPlayerController;
|
||||
|
||||
late CustomVideoPlayerController _customVideoPlayerController;
|
||||
late CustomVideoPlayerWebController _customVideoPlayerWebController;
|
||||
|
||||
final CustomVideoPlayerSettings _customVideoPlayerSettings =
|
||||
const CustomVideoPlayerSettings();
|
||||
|
||||
late CustomVideoPlayerWebSettings _customVideoPlayerWebSettings;
|
||||
|
||||
late VideoPlayerController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_videoPlayerController = VideoPlayerController.network(
|
||||
widget.videoUrl,
|
||||
)..initialize().then((value) => setState(() {}));
|
||||
_customVideoPlayerController = CustomVideoPlayerController(
|
||||
context: context,
|
||||
videoPlayerController: _videoPlayerController,
|
||||
customVideoPlayerSettings: _customVideoPlayerSettings,
|
||||
);
|
||||
|
||||
_customVideoPlayerWebSettings = CustomVideoPlayerWebSettings(
|
||||
src: widget.videoUrl,
|
||||
);
|
||||
|
||||
_customVideoPlayerWebController = CustomVideoPlayerWebController(
|
||||
webVideoPlayerSettings: _customVideoPlayerWebSettings,
|
||||
);
|
||||
|
||||
_controller = VideoPlayerController.network(widget.videoUrl)
|
||||
..initialize().then((_) {
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_customVideoPlayerController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: Colors.black,
|
||||
child: SafeArea(
|
||||
child: Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: _controller.value.aspectRatio,
|
||||
child: CustomVideoPlayerWeb(
|
||||
customVideoPlayerWebController: _customVideoPlayerWebController,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
80
assets/referencia/video_player_live.text
Normal file
80
assets/referencia/video_player_live.text
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:chewie/chewie.dart';
|
||||
|
||||
class VideoPlayerLive extends StatefulWidget {
|
||||
final String url;
|
||||
|
||||
const VideoPlayerLive({Key? key, required this.url}) : super(key: key);
|
||||
|
||||
@override
|
||||
_VideoPlayerLiveState createState() => _VideoPlayerLiveState();
|
||||
}
|
||||
|
||||
class _VideoPlayerLiveState extends State<VideoPlayerLive> {
|
||||
late ChewieController _chewieController;
|
||||
bool _isFullScreen = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initializePlayer();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_chewieController.dispose();
|
||||
}
|
||||
|
||||
void _initializePlayer() {
|
||||
final videoPlayerController = VideoPlayerController.network(widget.url);
|
||||
_chewieController = ChewieController(
|
||||
videoPlayerController: videoPlayerController,
|
||||
autoPlay: false,
|
||||
looping: false,
|
||||
showControls: true,
|
||||
allowFullScreen: true,
|
||||
allowMuting: true,
|
||||
allowPlaybackSpeedChanging: false,
|
||||
aspectRatio: videoPlayerController.value.aspectRatio,
|
||||
customControls: CupertinoControls(
|
||||
backgroundColor: Color.fromARGB(66, 0, 0, 0),
|
||||
iconColor: Color.fromARGB(255, 202, 202, 202),
|
||||
showPlayButton: true),
|
||||
);
|
||||
}
|
||||
|
||||
void _toggleFullScreen() {
|
||||
if (!_isFullScreen) {
|
||||
_chewieController.enterFullScreen();
|
||||
} else {
|
||||
_chewieController.exitFullScreen();
|
||||
}
|
||||
setState(() {
|
||||
_isFullScreen = !_isFullScreen;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Colors.black,
|
||||
child: Center(
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: _toggleFullScreen,
|
||||
child: AspectRatio(
|
||||
aspectRatio:
|
||||
_chewieController.videoPlayerController.value.aspectRatio,
|
||||
child: Chewie(
|
||||
controller: _chewieController,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
69
assets/referencia/video_thumbnail.dart
Normal file
69
assets/referencia/video_thumbnail.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
class VideoScreenThumbnail extends StatefulWidget {
|
||||
final dynamic video;
|
||||
const VideoScreenThumbnail({Key? key, required this.video}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<VideoScreenThumbnail> createState() => _VideoScreenThumbnailState();
|
||||
}
|
||||
|
||||
class _VideoScreenThumbnailState extends State<VideoScreenThumbnail> {
|
||||
late VideoPlayerController _controllerVideo;
|
||||
late bool startedPlaying;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controllerVideo = VideoPlayerController.network(widget.video);
|
||||
_controllerVideo.initialize();
|
||||
super.initState();
|
||||
started();
|
||||
_controllerVideo.setVolume(0);
|
||||
_controllerVideo.pause();
|
||||
}
|
||||
|
||||
Future<bool> started() async {
|
||||
var renderized = false;
|
||||
double height = 0;
|
||||
|
||||
await Future.delayed(const Duration(seconds: 2), () {
|
||||
height = _controllerVideo.value.size.height;
|
||||
if (height > 0) renderized = true;
|
||||
});
|
||||
|
||||
return renderized;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: started(),
|
||||
builder: ((context, AsyncSnapshot<bool> snapshot) {
|
||||
if (snapshot.data ?? false) {
|
||||
return Stack(
|
||||
alignment: AlignmentDirectional.center,
|
||||
children: [
|
||||
VideoPlayer(_controllerVideo),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: const [
|
||||
SizedBox(height: 30),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
var video = _controllerVideo;
|
||||
video.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user