fix: 快速返回首页&销毁播放器
This commit is contained in:
@ -97,7 +97,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
plPlayerController!.pause();
|
|
||||||
plPlayerController!.dispose();
|
plPlayerController!.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -483,10 +483,12 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
size: 15,
|
size: 15,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
fuc: () {
|
fuc: () async {
|
||||||
// 销毁播放器实例
|
// 销毁播放器实例
|
||||||
widget.controller!.dispose(type: 'all');
|
await widget.controller!.dispose(type: 'all');
|
||||||
Get.offAll(const MainApp());
|
if (mounted) {
|
||||||
|
Navigator.popUntil(context, (route) => route.isFirst);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
|||||||
@ -760,36 +760,39 @@ class PlPlayerController {
|
|||||||
|
|
||||||
Future<void> dispose({String type = 'single'}) async {
|
Future<void> dispose({String type = 'single'}) async {
|
||||||
// 每次减1,最后销毁
|
// 每次减1,最后销毁
|
||||||
if (type == 'single') {
|
if (type == 'single' && playerCount.value > 1) {
|
||||||
_playerCount.value -= 1;
|
_playerCount.value -= 1;
|
||||||
_heartDuration = 0;
|
_heartDuration = 0;
|
||||||
if (playerCount.value > 0) {
|
pause();
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
_playerCount.value = 0;
|
||||||
|
try {
|
||||||
|
_timer?.cancel();
|
||||||
|
_timerForVolume?.cancel();
|
||||||
|
_timerForGettingVolume?.cancel();
|
||||||
|
timerForTrackingMouse?.cancel();
|
||||||
|
_timerForSeek?.cancel();
|
||||||
|
videoFitChangedTimer?.cancel();
|
||||||
|
// _position.close();
|
||||||
|
_playerEventSubs?.cancel();
|
||||||
|
// _sliderPosition.close();
|
||||||
|
// _sliderTempPosition.close();
|
||||||
|
// _isSliderMoving.close();
|
||||||
|
// _duration.close();
|
||||||
|
// _buffered.close();
|
||||||
|
// _showControls.close();
|
||||||
|
// _controlsLock.close();
|
||||||
|
|
||||||
_timer?.cancel();
|
// playerStatus.status.close();
|
||||||
_timerForVolume?.cancel();
|
// dataStatus.status.close();
|
||||||
_timerForGettingVolume?.cancel();
|
|
||||||
timerForTrackingMouse?.cancel();
|
|
||||||
_timerForSeek?.cancel();
|
|
||||||
videoFitChangedTimer?.cancel();
|
|
||||||
_position.close();
|
|
||||||
_playerEventSubs?.cancel();
|
|
||||||
_sliderPosition.close();
|
|
||||||
_sliderTempPosition.close();
|
|
||||||
_isSliderMoving.close();
|
|
||||||
_duration.close();
|
|
||||||
_buffered.close();
|
|
||||||
_showControls.close();
|
|
||||||
_controlsLock.close();
|
|
||||||
|
|
||||||
playerStatus.status.close();
|
removeListeners();
|
||||||
dataStatus.status.close();
|
await _videoPlayerController?.dispose();
|
||||||
|
_videoPlayerController = null;
|
||||||
removeListeners();
|
_instance = null;
|
||||||
await _videoPlayerController?.dispose();
|
} catch (err) {
|
||||||
_videoPlayerController = null;
|
print(err);
|
||||||
_instance = null;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user