- cached_video_player - musicplaceholder as asset
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
||||
|
||||
class VideoControlsOverlay extends StatelessWidget {
|
||||
final VideoPlayerController controller;
|
||||
final CachedVideoPlayerPlusController controller;
|
||||
final VoidCallback button;
|
||||
|
||||
const VideoControlsOverlay({
|
||||
@ -76,7 +76,7 @@ class _ControlButton extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _ProgressIndicator extends StatelessWidget {
|
||||
final VideoPlayerController controller;
|
||||
final CachedVideoPlayerPlusController controller;
|
||||
|
||||
const _ProgressIndicator({required this.controller});
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:f0ckapp/models/MediaItem.dart';
|
||||
import 'package:f0ckapp/widgets/VideoOverlay.dart';
|
||||
import 'dart:async';
|
||||
|
||||
class VideoWidget extends StatefulWidget {
|
||||
final MediaItem details;
|
||||
@ -15,7 +14,7 @@ class VideoWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _VideoWidgetState extends State<VideoWidget> {
|
||||
late VideoPlayerController _controller;
|
||||
late CachedVideoPlayerPlusController _controller;
|
||||
bool _showControls = false;
|
||||
Timer? _hideControlsTimer;
|
||||
|
||||
@ -26,7 +25,7 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
}
|
||||
|
||||
Future<void> _initController() async {
|
||||
_controller = VideoPlayerController.networkUrl(
|
||||
_controller = CachedVideoPlayerPlusController.networkUrl(
|
||||
Uri.parse(widget.details.mediaUrl),
|
||||
);
|
||||
await _controller.initialize();
|
||||
@ -69,7 +68,7 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
? _controller.value.aspectRatio
|
||||
: 9 / 16,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
alignment: Alignment.topCenter,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: _onTap,
|
||||
@ -79,17 +78,29 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => Image.network(
|
||||
"https://f0ck.me/s/img/music.webp",
|
||||
errorWidget: (context, url, error) => Image.asset(
|
||||
'assets/images/music.webp',
|
||||
fit: BoxFit.contain,
|
||||
width: double.infinity
|
||||
),
|
||||
)
|
||||
: _controller.value.isInitialized
|
||||
? VideoPlayer(_controller)
|
||||
? CachedVideoPlayerPlus(_controller)
|
||||
: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
if (_controller.value.isInitialized && _showControls) ...[
|
||||
VideoControlsOverlay(controller: _controller, button: () => _onTap(ctrlButton: true)),
|
||||
IgnorePointer(
|
||||
ignoring: true,
|
||||
child: Container(
|
||||
color: Colors.black.withValues(alpha: 0.5),
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
),
|
||||
),
|
||||
VideoControlsOverlay(
|
||||
controller: _controller,
|
||||
button: () => _onTap(ctrlButton: true),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
Reference in New Issue
Block a user