mod: 视频播放器重构 - 基本功能
This commit is contained in:
55
lib/plugin/pl_player/models/data_source.dart
Normal file
55
lib/plugin/pl_player/models/data_source.dart
Normal file
@ -0,0 +1,55 @@
|
||||
import 'dart:io';
|
||||
|
||||
/// The way in which the video was originally loaded.
|
||||
///
|
||||
/// This has nothing to do with the video's file type. It's just the place
|
||||
/// from which the video is fetched from.
|
||||
enum DataSourceType {
|
||||
/// The video was included in the app's asset files.
|
||||
asset,
|
||||
|
||||
/// The video was downloaded from the internet.
|
||||
network,
|
||||
|
||||
/// The video was loaded off of the local filesystem.
|
||||
file,
|
||||
|
||||
/// The video is available via contentUri. Android only.
|
||||
contentUri,
|
||||
}
|
||||
|
||||
class DataSource {
|
||||
File? file;
|
||||
String? videoSource;
|
||||
String? audioSource;
|
||||
String? subFiles;
|
||||
DataSourceType type;
|
||||
Map<String, String>? httpHeaders; // for headers
|
||||
DataSource({
|
||||
this.file,
|
||||
this.videoSource,
|
||||
this.audioSource,
|
||||
this.subFiles,
|
||||
required this.type,
|
||||
this.httpHeaders,
|
||||
}) : assert((type == DataSourceType.file && file != null) ||
|
||||
videoSource != null);
|
||||
|
||||
DataSource copyWith({
|
||||
File? file,
|
||||
String? videoSource,
|
||||
String? audioSource,
|
||||
String? subFiles,
|
||||
DataSourceType? type,
|
||||
Map<String, String>? httpHeaders,
|
||||
}) {
|
||||
return DataSource(
|
||||
file: file ?? this.file,
|
||||
videoSource: videoSource ?? this.videoSource,
|
||||
audioSource: audioSource ?? this.audioSource,
|
||||
subFiles: subFiles ?? this.subFiles,
|
||||
type: type ?? this.type,
|
||||
httpHeaders: httpHeaders ?? this.httpHeaders,
|
||||
);
|
||||
}
|
||||
}
|
||||
12
lib/plugin/pl_player/models/data_status.dart
Normal file
12
lib/plugin/pl_player/models/data_status.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
enum DataStatus { none, loading, loaded, error }
|
||||
|
||||
class PlPlayerDataStatus {
|
||||
Rx<DataStatus> status = Rx(DataStatus.none);
|
||||
|
||||
bool get none => status.value == DataStatus.none;
|
||||
bool get loading => status.value == DataStatus.loading;
|
||||
bool get loaded => status.value == DataStatus.loaded;
|
||||
bool get error => status.value == DataStatus.error;
|
||||
}
|
||||
19
lib/plugin/pl_player/models/play_status.dart
Normal file
19
lib/plugin/pl_player/models/play_status.dart
Normal file
@ -0,0 +1,19 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
enum PlayerStatus { completed, playing, paused }
|
||||
|
||||
class PlPlayerStatus {
|
||||
Rx<PlayerStatus> status = Rx(PlayerStatus.paused);
|
||||
|
||||
bool get playing {
|
||||
return status.value == PlayerStatus.playing;
|
||||
}
|
||||
|
||||
bool get paused {
|
||||
return status.value == PlayerStatus.paused;
|
||||
}
|
||||
|
||||
bool get completed {
|
||||
return status.value == PlayerStatus.completed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user