mirror of
https://github.com/ndarilek/tts-rs.git
synced 2024-11-23 03:59:37 +00:00
Fix more queuing issues under WinRT.
This commit is contained in:
parent
204cd50935
commit
031e0ff23f
|
@ -149,16 +149,17 @@ impl Backend for WinRT {
|
||||||
text: &str,
|
text: &str,
|
||||||
interrupt: bool,
|
interrupt: bool,
|
||||||
) -> std::result::Result<Option<UtteranceId>, Error> {
|
) -> std::result::Result<Option<UtteranceId>, Error> {
|
||||||
if interrupt {
|
|
||||||
self.stop()?;
|
|
||||||
}
|
|
||||||
let stream = self.synth.synthesize_text_to_stream_async(text)?.get()?;
|
let stream = self.synth.synthesize_text_to_stream_async(text)?.get()?;
|
||||||
let content_type = stream.content_type()?;
|
let content_type = stream.content_type()?;
|
||||||
let source = MediaSource::create_from_stream(stream, content_type)?;
|
let source = MediaSource::create_from_stream(stream, content_type)?;
|
||||||
let item = MediaPlaybackItem::create(source)?;
|
let item = MediaPlaybackItem::create(source)?;
|
||||||
let item_index = self.playback_list.current_item_index()?;
|
let item_index = self.playback_list.current_item_index()?;
|
||||||
|
let item_count = self.playback_list.items()?.size()?;
|
||||||
let state = self.player.playback_session()?.playback_state()?;
|
let state = self.player.playback_session()?.playback_state()?;
|
||||||
if state == MediaPlaybackState::Paused && item_index != 0 {
|
if interrupt && state != MediaPlaybackState::Paused {
|
||||||
|
self.stop()?;
|
||||||
|
}
|
||||||
|
if state == MediaPlaybackState::Paused && item_index != 0 && item_index < item_count {
|
||||||
self.playback_list.items()?.clear()?;
|
self.playback_list.items()?.clear()?;
|
||||||
}
|
}
|
||||||
self.playback_list.items()?.append(&item)?;
|
self.playback_list.items()?.append(&item)?;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user