import 'package:flutter/material.dart';
import 'package:gz_video_player/video.dart';

class OtherTestPage extends StatefulWidget {
  const OtherTestPage({super.key});

  @override
  State<StatefulWidget> createState() => _OtherTestPageState();
}

class _OtherTestPageState extends State<OtherTestPage> {
  String url = 'https://mpv.videocc.net/8f38fa3352/7/8f38fa335252dea652836243dd7e3f97_1.mp4';
      // 'https://mpv.videocc.net/8f38fa3352/c/8f38fa3352a8cc8f70dd384edb9b21dc_1.mp4';

  late VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.networkUrl(Uri.parse(url));
    _controller.initialize().then((value) {
      _controller.play();
    });
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('other test page'),
      ),
      body: Column(
        children: [
          // GZVideoPlayer(
          //   dataSource: url,
          //   sourceType: DataSourceType.network,
          //   restoreVertical: false,
          // ),
          AspectRatio(
            aspectRatio: 16 / 9,
            child: VideoPlayer(_controller),
          ),

          GestureDetector(
            onTap: () {
              _controller.setPlaybackSpeed(2.0);
            },
            behavior: HitTestBehavior.translucent,
            child: Container(
              width: 100,
              height: 40,
              color: Colors.black.withOpacity(0.5),
              alignment: Alignment.center,
              child: const Text('2倍速'),
            ),
          ),

          GestureDetector(
            onTap: () {
              _controller.seekTo(const Duration(seconds: 22));
            },
            behavior: HitTestBehavior.translucent,
            child: Container(
              width: 100,
              height: 40,
              color: Colors.black.withOpacity(0.5),
              alignment: Alignment.center,
              child: const Text('sekTo'),
            ),
          )
        ],
      ),
    );
  }
}
