File size: 1,733 Bytes
2e813e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// lib/services/clip_queue/clip_states.dart

import 'dart:async';
import 'package:flutter/foundation.dart';

/// Represents the different states a video clip can be in during its lifecycle
enum ClipState {
  /// The clip is waiting to be generated
  generationPending,
  
  /// The clip is currently being generated
  generationInProgress,
  
  /// The clip has been generated and is ready to be played
  generatedAndReadyToPlay,
  
  /// The clip has been generated and is currently playing
  generatedAndPlaying,
  
  /// The clip generation failed
  failedToGenerate,
  
  /// The clip has been generated and has been played
  generatedAndPlayed
}

/// Constants for clip queue management
class ClipQueueConstants {
  /// The delay before retrying a failed clip generation
  static const Duration retryDelay = Duration(seconds: 2);
  
  /// The timeout for a clip generation before it is considered stuck
  static const Duration clipTimeout = Duration(seconds: 90);
  
  /// The timeout for the actual generation process
  static const Duration generationTimeout = Duration(seconds: 60);
  
  /// Whether to show logs in debug mode
  static const bool showLogsInDebugMode = false;
  
  /// Maximum number of generation times to store for averaging
  static const int maxStoredGenerationTimes = 10;
  
  /// Helper function to avoid having to type unawaited everywhere
  static void unawaited(Future<void> future) {
    // This function intentionally does nothing.
    // It's used to explicitly mark that we're not waiting for this Future.
  }
  
  /// Logs an event if debug mode is enabled
  static void logEvent(String message) {
    if (showLogsInDebugMode && kDebugMode) {
      debugPrint('ClipQueue: $message');
    }
  }
}