Skip to content

Commit

Permalink
fix: crash when trying to get video transcription in main thread (ope…
Browse files Browse the repository at this point in the history
  • Loading branch information
dixidroid authored Dec 19, 2023
1 parent 0fd9238 commit 6c4cfe9
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -74,9 +75,9 @@ open class VideoUnitViewModel(
}

fun downloadSubtitles() {
viewModelScope.launch {
viewModelScope.launch(Dispatchers.IO) {
transcriptManager.downloadTranscriptsForVideo(getTranscriptUrl())?.let { result ->
_transcriptObject.value = result
_transcriptObject.postValue(result)
timeList = result.captions.values.toList()
.map { it.start.mseconds.toLong() }
}
Expand Down

0 comments on commit 6c4cfe9

Please sign in to comment.