video_rendering_preference.dart 748 Bytes
import 'package:flutter/foundation.dart';
import 'package:video_player/video_player.dart';
import 'package:wow_english/utils/sp_util.dart';

/// User-selectable Android video output path for device compatibility testing.
class VideoRenderingPreference {
  static const _usePlatformViewKey = 'video_player_use_platform_view';

  static bool get usesPlatformView =>
      SpUtil.getInstance().get<bool>(_usePlatformViewKey) ?? false;

  static VideoViewType get viewType =>
      defaultTargetPlatform == TargetPlatform.android && usesPlatformView
          ? VideoViewType.platformView
          : VideoViewType.textureView;

  static Future<void> setUsesPlatformView(bool value) =>
      SpUtil.getInstance().setData(_usePlatformViewKey, value);
}