mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Program screen: Close, if player is inactive
This commit is contained in:
parent
952f0b0c98
commit
27514ab11b
1 changed files with 14 additions and 0 deletions
|
|
@ -100,6 +100,8 @@ class ProgramScreen extends StatefulWidget {
|
||||||
class _ProgramScreenState extends State<ProgramScreen> {
|
class _ProgramScreenState extends State<ProgramScreen> {
|
||||||
BackendState backend;
|
BackendState backend;
|
||||||
|
|
||||||
|
StreamSubscription<bool> playerActiveSubscription;
|
||||||
|
|
||||||
StreamSubscription<List<InternalTrack>> playlistSubscription;
|
StreamSubscription<List<InternalTrack>> playlistSubscription;
|
||||||
List<ProgramItem> items = [];
|
List<ProgramItem> items = [];
|
||||||
|
|
||||||
|
|
@ -113,6 +115,17 @@ class _ProgramScreenState extends State<ProgramScreen> {
|
||||||
|
|
||||||
backend = Backend.of(context);
|
backend = Backend.of(context);
|
||||||
|
|
||||||
|
if (playerActiveSubscription != null) {
|
||||||
|
playerActiveSubscription.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the program screen, if the player is no longer active.
|
||||||
|
playerActiveSubscription = backend.player.active.listen((active) {
|
||||||
|
if (!active) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (playlistSubscription != null) {
|
if (playlistSubscription != null) {
|
||||||
playlistSubscription.cancel();
|
playlistSubscription.cancel();
|
||||||
}
|
}
|
||||||
|
|
@ -337,6 +350,7 @@ class _ProgramScreenState extends State<ProgramScreen> {
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
playerActiveSubscription.cancel();
|
||||||
playlistSubscription.cancel();
|
playlistSubscription.cancel();
|
||||||
positionSubscription.cancel();
|
positionSubscription.cancel();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue