mirror of
				https://github.com/Dummi26/musicdb.git
				synced 2025-11-03 21:16:16 +01:00 
			
		
		
		
	fixed bugs with playback when paused
This commit is contained in:
		
							parent
							
								
									f625233a1b
								
							
						
					
					
						commit
						55590a1549
					
				@ -82,8 +82,6 @@ impl Player {
 | 
				
			|||||||
                // db.playing, but no song in queue...
 | 
					                // db.playing, but no song in queue...
 | 
				
			||||||
                db.apply_command(Command::Stop);
 | 
					                db.apply_command(Command::Stop);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else if !db.playing && self.source.is_some() {
 | 
					 | 
				
			||||||
            self.current_song_id = SongOpt::New(None);
 | 
					 | 
				
			||||||
        } else if let Some((_source, notif)) = &mut self.source {
 | 
					        } else if let Some((_source, notif)) = &mut self.source {
 | 
				
			||||||
            if let Ok(()) = notif.try_recv() {
 | 
					            if let Ok(()) = notif.try_recv() {
 | 
				
			||||||
                // song has finished playing
 | 
					                // song has finished playing
 | 
				
			||||||
@ -121,10 +119,12 @@ impl Player {
 | 
				
			|||||||
                        Some(s) => s.to_str().unwrap_or(""),
 | 
					                        Some(s) => s.to_str().unwrap_or(""),
 | 
				
			||||||
                        None => "",
 | 
					                        None => "",
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
 | 
					                    if db.playing {
 | 
				
			||||||
                        if let Some(bytes) = song.cached_data_now(db) {
 | 
					                        if let Some(bytes) = song.cached_data_now(db) {
 | 
				
			||||||
                            match Self::sound_from_bytes(ext, bytes) {
 | 
					                            match Self::sound_from_bytes(ext, bytes) {
 | 
				
			||||||
                                Ok(v) => {
 | 
					                                Ok(v) => {
 | 
				
			||||||
                                let (sound, notif) = v.pausable().with_async_completion_notifier();
 | 
					                                    let (sound, notif) =
 | 
				
			||||||
 | 
					                                        v.pausable().with_async_completion_notifier();
 | 
				
			||||||
                                    // add it
 | 
					                                    // add it
 | 
				
			||||||
                                    let (sound, controller) = sound.controllable();
 | 
					                                    let (sound, controller) = sound.controllable();
 | 
				
			||||||
                                    self.source = Some((controller, notif));
 | 
					                                    self.source = Some((controller, notif));
 | 
				
			||||||
@ -137,6 +137,10 @@ impl Player {
 | 
				
			|||||||
                                }
 | 
					                                }
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        self.source = None;
 | 
				
			||||||
 | 
					                        song.cache_data_start_thread(&db);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    panic!("invalid song ID: current_song_id not found in DB!");
 | 
					                    panic!("invalid song ID: current_song_id not found in DB!");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user