- cached_video_player - musicplaceholder as asset
This commit is contained in:
parent
c236049c0a
commit
7130ad9817
BIN
assets/images/music.webp
Normal file
BIN
assets/images/music.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 634 KiB |
@ -14,7 +14,7 @@ class MediaGrid extends StatefulWidget {
|
|||||||
|
|
||||||
class _MediaGridState extends State<MediaGrid> {
|
class _MediaGridState extends State<MediaGrid> {
|
||||||
final ScrollController _scrollController = ScrollController();
|
final ScrollController _scrollController = ScrollController();
|
||||||
final String _version = '1.0.22+22';
|
final String _version = '1.0.23+23';
|
||||||
List<MediaItem> mediaItems = [];
|
List<MediaItem> mediaItems = [];
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
Timer? _debounceTimer;
|
Timer? _debounceTimer;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
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 {
|
class VideoControlsOverlay extends StatelessWidget {
|
||||||
final VideoPlayerController controller;
|
final CachedVideoPlayerPlusController controller;
|
||||||
final VoidCallback button;
|
final VoidCallback button;
|
||||||
|
|
||||||
const VideoControlsOverlay({
|
const VideoControlsOverlay({
|
||||||
@ -76,7 +76,7 @@ class _ControlButton extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ProgressIndicator extends StatelessWidget {
|
class _ProgressIndicator extends StatelessWidget {
|
||||||
final VideoPlayerController controller;
|
final CachedVideoPlayerPlusController controller;
|
||||||
|
|
||||||
const _ProgressIndicator({required this.controller});
|
const _ProgressIndicator({required this.controller});
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
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:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:f0ckapp/models/MediaItem.dart';
|
import 'package:f0ckapp/models/MediaItem.dart';
|
||||||
import 'package:f0ckapp/widgets/VideoOverlay.dart';
|
import 'package:f0ckapp/widgets/VideoOverlay.dart';
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
class VideoWidget extends StatefulWidget {
|
class VideoWidget extends StatefulWidget {
|
||||||
final MediaItem details;
|
final MediaItem details;
|
||||||
@ -15,7 +14,7 @@ class VideoWidget extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _VideoWidgetState extends State<VideoWidget> {
|
class _VideoWidgetState extends State<VideoWidget> {
|
||||||
late VideoPlayerController _controller;
|
late CachedVideoPlayerPlusController _controller;
|
||||||
bool _showControls = false;
|
bool _showControls = false;
|
||||||
Timer? _hideControlsTimer;
|
Timer? _hideControlsTimer;
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ class _VideoWidgetState extends State<VideoWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initController() async {
|
Future<void> _initController() async {
|
||||||
_controller = VideoPlayerController.networkUrl(
|
_controller = CachedVideoPlayerPlusController.networkUrl(
|
||||||
Uri.parse(widget.details.mediaUrl),
|
Uri.parse(widget.details.mediaUrl),
|
||||||
);
|
);
|
||||||
await _controller.initialize();
|
await _controller.initialize();
|
||||||
@ -69,7 +68,7 @@ class _VideoWidgetState extends State<VideoWidget> {
|
|||||||
? _controller.value.aspectRatio
|
? _controller.value.aspectRatio
|
||||||
: 9 / 16,
|
: 9 / 16,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.topCenter,
|
||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: _onTap,
|
onTap: _onTap,
|
||||||
@ -79,17 +78,29 @@ class _VideoWidgetState extends State<VideoWidget> {
|
|||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
placeholder: (context, url) =>
|
placeholder: (context, url) =>
|
||||||
CircularProgressIndicator(),
|
CircularProgressIndicator(),
|
||||||
errorWidget: (context, url, error) => Image.network(
|
errorWidget: (context, url, error) => Image.asset(
|
||||||
"https://f0ck.me/s/img/music.webp",
|
'assets/images/music.webp',
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
|
width: double.infinity
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: _controller.value.isInitialized
|
: _controller.value.isInitialized
|
||||||
? VideoPlayer(_controller)
|
? CachedVideoPlayerPlus(_controller)
|
||||||
: Center(child: CircularProgressIndicator()),
|
: Center(child: CircularProgressIndicator()),
|
||||||
),
|
),
|
||||||
if (_controller.value.isInitialized && _showControls) ...[
|
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),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
32
pubspec.lock
32
pubspec.lock
@ -41,6 +41,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.1"
|
version: "1.3.1"
|
||||||
|
cached_video_player_plus:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: cached_video_player_plus
|
||||||
|
sha256: "451ee48bdbd28fac3d49b4389929c44d259b1def5be6dab0c5bfd3ae1f05e8b5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.3"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -152,6 +160,22 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
get:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: get
|
||||||
|
sha256: c79eeb4339f1f3deffd9ec912f8a923834bec55f7b49c9e882b8fef2c139d425
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.7.2"
|
||||||
|
get_storage:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: get_storage
|
||||||
|
sha256: "39db1fffe779d0c22b3a744376e86febe4ade43bf65e06eab5af707dc84185a2"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.1"
|
||||||
html:
|
html:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -453,14 +477,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.2.0"
|
||||||
video_player:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: video_player
|
|
||||||
sha256: "7d78f0cfaddc8c19d4cb2d3bebe1bfef11f2103b0a03e5398b303a1bf65eeb14"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.9.5"
|
|
||||||
video_player_android:
|
video_player_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.0.22+22
|
version: 1.0.23+23
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.9.0-100.2.beta
|
sdk: ^3.9.0-100.2.beta
|
||||||
@ -31,12 +31,12 @@ dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
http: ^1.4.0
|
http: ^1.4.0
|
||||||
video_player: ^2.2.10
|
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
cached_network_image: ^3.4.1
|
cached_network_image: ^3.4.1
|
||||||
|
cached_video_player_plus: ^3.0.3
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@ -61,7 +61,8 @@ flutter:
|
|||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
# assets:
|
assets:
|
||||||
|
- assets/images/
|
||||||
# - images/a_dot_burr.jpeg
|
# - images/a_dot_burr.jpeg
|
||||||
# - images/a_dot_ham.jpeg
|
# - images/a_dot_ham.jpeg
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user