播放器修改,功能完善
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/core/logging/i_logger_service.dart';
|
||||
import 'package:maibu_satabot_v2/core/protocol/packet_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/remote_control/domain/entities/running_status_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/remote_control/presentation/bloc/remote_control_state.dart';
|
||||
import '../../../../core/di/injection.dart';
|
||||
import '../../../connectivity/presentation/bloc/connectivity_cubit.dart';
|
||||
import '../../domain/entities/machine_control_entity.dart';
|
||||
import '../../domain/repositories/remote_control_repository.dart';
|
||||
|
||||
class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
final RemoteControlRepository _repository;
|
||||
final ConnectivityCubit connectivityCubit;
|
||||
|
||||
// 定时器与流订阅管理
|
||||
Timer? _timer;
|
||||
StreamSubscription<RunningStatusEntity>? _statusSubscription;
|
||||
StreamSubscription<PacketEntity>? _responseSubscription;
|
||||
|
||||
RemoteControlCubit(this._repository)
|
||||
RemoteControlCubit(this._repository,this.connectivityCubit)
|
||||
: super(
|
||||
RemoteControlState(
|
||||
controlEntity: MachineControlEntity(),
|
||||
@@ -153,6 +157,32 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
void toggleLeftPip() => emit(state.copyWith(showLeftPip: !state.showLeftPip));
|
||||
void toggleRightPip() => emit(state.copyWith(showRightPip: !state.showRightPip));
|
||||
|
||||
void toggleTopLeftExpand() {
|
||||
emit(state.copyWith(topRightIsExpanded: !state.topRightIsExpanded));
|
||||
}
|
||||
|
||||
void toggleObstacleRecognition() {
|
||||
emit(state.copyWith(obstacleRecognitionFlag: !state.obstacleRecognitionFlag));
|
||||
}
|
||||
|
||||
void initVideoUrls(String main, String ai) {
|
||||
emit(state.copyWith(
|
||||
mainStreamUrl: main,
|
||||
aiStreamUrl: ai,
|
||||
isVideoEnabled: true,
|
||||
));
|
||||
}
|
||||
|
||||
void disposeVideo() {
|
||||
emit(state.copyWith(
|
||||
mainStreamUrl: "",
|
||||
aiStreamUrl: "",
|
||||
isVideoEnabled: false,
|
||||
obstacleRecognitionFlag: false,
|
||||
));
|
||||
sl<ILoggerService>().log("Cubit: 视频地址已置空,准备断开连接");
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 4. 销毁与清理 (Cleanup)
|
||||
// ==========================================
|
||||
@@ -164,4 +194,5 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
_responseSubscription?.cancel();
|
||||
return super.close();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user