LCOV - code coverage report
Current view: top level - utils - functions.dart Coverage Total Hit
Test: lcov_cleaned.info Lines: 0.0 % 6 0
Test Date: 2025-06-20 10:50:47 Functions: - 0 0

            Line data    Source code
       1              : import '../entities/entities.dart';
       2              : 
       3              : /// Calculates the playback percentage based on current position and total duration.
       4              : ///
       5              : /// This function computes how much of the media has been played as a percentage
       6              : /// (0.0 to 1.0) based on the current playback position and the total media duration.
       7              : ///
       8              : /// Returns null if either the current duration or media duration is null or zero.
       9              : /// Returns 1.0 if the percentage would exceed 100% (should not normally happen).
      10              : ///
      11              : /// [mediaStatus] - The current media status containing duration information
      12              : /// [currentDuration] - The current playback position
      13            0 : double? getPlayerPercentage(
      14              :     GoggleCastMediaStatus mediaStatus, Duration? currentDuration) {
      15            0 :   if (currentDuration == null || currentDuration.inSeconds == 0) return null;
      16            0 :   final mediaDuration = mediaStatus.mediaInformation?.duration;
      17            0 :   if (mediaDuration == null || mediaDuration.inSeconds == 0) return null;
      18            0 :   final percentage = currentDuration.inSeconds / mediaDuration.inSeconds;
      19            0 :   if (percentage > 1) return 1;
      20              :   return percentage;
      21              : }
        

Generated by: LCOV version 2.3.1-1