- fix deeplink - add mute button
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
import 'dart:async';
 | 
			
		||||
 | 
			
		||||
import 'package:f0ckapp/services/api_service.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
 | 
			
		||||
@@ -7,6 +8,7 @@ import 'package:cached_network_image/cached_network_image.dart';
 | 
			
		||||
 | 
			
		||||
import 'package:f0ckapp/models/mediaitem_model.dart';
 | 
			
		||||
import 'package:f0ckapp/widgets/videooverlay_widget.dart';
 | 
			
		||||
import 'package:get/get.dart';
 | 
			
		||||
 | 
			
		||||
class VideoWidget extends StatefulWidget {
 | 
			
		||||
  final MediaItem details;
 | 
			
		||||
@@ -25,6 +27,7 @@ class VideoWidget extends StatefulWidget {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _VideoWidgetState extends State<VideoWidget> {
 | 
			
		||||
  final ApiService apiService = Get.find<ApiService>();
 | 
			
		||||
  late CachedVideoPlayerPlusController _controller;
 | 
			
		||||
  bool _showControls = false;
 | 
			
		||||
  Timer? _hideControlsTimer;
 | 
			
		||||
@@ -49,8 +52,7 @@ class _VideoWidgetState extends State<VideoWidget> {
 | 
			
		||||
    }
 | 
			
		||||
    _controller.setLooping(true);
 | 
			
		||||
 | 
			
		||||
    //final bool muted = ref.read(mediaProvider).muted;
 | 
			
		||||
    //_controller.setVolume(muted ? 0.0 : 1.0);
 | 
			
		||||
    _controller.setVolume(apiService.muted.value ? 0.0 : 1.0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
@@ -86,11 +88,11 @@ class _VideoWidgetState extends State<VideoWidget> {
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    //final bool muted = ref.watch(mediaProvider).muted;
 | 
			
		||||
    //if (_controller.value.isInitialized &&
 | 
			
		||||
    //    _controller.value.volume != (muted ? 0.0 : 1.0)) {
 | 
			
		||||
    //  _controller.setVolume(muted ? 0.0 : 1.0);
 | 
			
		||||
    //}
 | 
			
		||||
    final bool muted = apiService.muted.value;
 | 
			
		||||
    if (_controller.value.isInitialized &&
 | 
			
		||||
        _controller.value.volume != (muted ? 0.0 : 1.0)) {
 | 
			
		||||
      _controller.setVolume(muted ? 0.0 : 1.0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool isAudio = widget.details.mime.startsWith('audio');
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
import 'package:f0ckapp/services/api_service.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
 | 
			
		||||
import 'package:get/get.dart';
 | 
			
		||||
 | 
			
		||||
class VideoControlsOverlay extends StatelessWidget {
 | 
			
		||||
  final CachedVideoPlayerPlusController controller;
 | 
			
		||||
@@ -14,10 +16,25 @@ class VideoControlsOverlay extends StatelessWidget {
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    final ApiService apiService = Get.find<ApiService>();
 | 
			
		||||
 | 
			
		||||
    return Stack(
 | 
			
		||||
      alignment: Alignment.center,
 | 
			
		||||
      children: [
 | 
			
		||||
        Positioned(
 | 
			
		||||
          right: 12,
 | 
			
		||||
          bottom: 12,
 | 
			
		||||
          child: Obx(
 | 
			
		||||
            () => _ControlButton(
 | 
			
		||||
              apiService.muted.value ? Icons.volume_off : Icons.volume_up,
 | 
			
		||||
              () async {
 | 
			
		||||
                button();
 | 
			
		||||
                await apiService.toggleMuted();
 | 
			
		||||
              },
 | 
			
		||||
              size: 16,
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
        ),
 | 
			
		||||
        Center(
 | 
			
		||||
          child: Row(
 | 
			
		||||
            mainAxisAlignment: MainAxisAlignment.center,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user