getVideoWidget method

  1. @override
Widget getVideoWidget()
override

Implementation

@override
Widget getVideoWidget() {
  return Obx(() {
    if (!isValidVideo.value) {
      return CachedNetworkImage(
        imageUrl: videoUrl,
        fit: BoxFit.cover,
      );
    }
    if (!isInitialized.value) {
      return Center(
        child: CupertinoActivityIndicator(),
      );
    }

    return Stack(
      fit: StackFit.expand,
      children: [
        FittedBox(
          fit: BoxFit.cover,
          child: SizedBox(
            width: player.value.size.width,
            height: player.value.size.height,
            child: VideoPlayer(player),
          ),
        ),
        Align(
          alignment: Alignment.bottomRight,
          child: Obx(() {
            if (isMuted.value) {
              return IconButton(
                icon: Icon(Icons.volume_off, color: Colors.white),
                onPressed: () async {
                  await setVolume(1.0);
                },
              );
            }
            return SizedBox.shrink();
          }),
        ),
        if (1 == 1)
          Align(
            alignment: Alignment.bottomCenter,
            child: VideoProgressIndicator(
              player,
              allowScrubbing: true,
              colors: VideoProgressColors(
                playedColor: Colors.white,
                bufferedColor: Colors.grey,
                backgroundColor: Colors.black54,
              ),
            ),
          ),
        if (1 == 1)
          Align(
            alignment: Alignment.bottomCenter,
            child: SizedBox(
              height: 5,
              child: SliderTheme(
                data: SliderTheme.of(Get.context!).copyWith(
                  thumbShape: SliderComponentShape.noThumb,
                  padding: EdgeInsets.all(0),
                ),
                child: Slider(
                  padding: EdgeInsets.all(0),

                  divisions: null, // Bu şekilde smooth olur
                  min: 0,
                  max: player.value.duration.inMilliseconds.toDouble(),
                  value: currentPosition.value.clamp(
                      0, player.value.duration.inMilliseconds.toDouble()),
                  onChanged: (value) {
                    player.seekTo(Duration(milliseconds: value.toInt()));
                    currentPosition.value =
                        value; // Kullanıcı kaydırınca da güncelle
                  },
                  activeColor: Colors.red,
                  inactiveColor: Colors.grey,
                ),
              ),
            ),
          ),
      ],
    );
  });
}