Update gtk154

This commit is contained in:
daleclack 2023-09-26 17:10:27 +08:00
parent 43b1729d05
commit 4ff5f722d3
2 changed files with 16 additions and 8 deletions

View File

@ -323,9 +323,12 @@ static void reset_lyrics(gint64 timestamp, GtkMediaStream *stream,
lyrics_label_update(timestamp, player);
// Pause audio before seek to avoid isolation
gtk_media_stream_pause(stream);
gtk_media_stream_seek(stream, timestamp * 1000);
gtk_media_stream_play(stream);
if (timestamp != 0)
{
gtk_media_stream_pause(stream);
gtk_media_stream_seek(stream, timestamp * 1000);
gtk_media_stream_play(stream);
}
}
// Check whether the media is playing
@ -339,7 +342,8 @@ static gboolean get_media_playing(gint64 curr_time,
}
else
{
if (abs(curr_time - tmp_time) > 500)
gint64 delta_time = abs(curr_time - tmp_time);
if (delta_time > 500)
{
// Reset lyrics load status
reset_lyrics(curr_time, stream, player);
@ -360,15 +364,16 @@ static gboolean get_media_stream_status(MyMediaPlayer *player,
}
// The Media ended, reset the status
if (gtk_media_stream_get_ended(stream))
{
lyrics_loaded = FALSE;
}
// if (gtk_media_stream_get_ended(stream))
// {
// lyrics_loaded = FALSE;
// }
if (get_media_playing(timestamp, stream, player))
{
// Reset status when the media playing
lyrics_updated = FALSE;
lyrics_loaded = TRUE;
return TRUE;
}
else

View File

@ -179,6 +179,8 @@ static void my_media_player_init(MyMediaPlayer *self)
self->btn_remove = gtk_button_new_from_icon_name("list-remove");
self->btn_load = gtk_button_new_from_icon_name("go-up");
self->btn_save = gtk_button_new_from_icon_name("document-save");
// Initalize widgets
gtk_widget_set_size_request(self->video, 300, 150);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(self->scrolled_window),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
@ -186,6 +188,7 @@ static void my_media_player_init(MyMediaPlayer *self)
GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
gtk_label_set_markup(GTK_LABEL(self->label_lyrics),
"<span color=\"red\" size='12pt'>No media file playing!</span>");
gtk_video_set_autoplay(GTK_VIDEO(self->video), FALSE);
// Link signals for buttons
g_signal_connect(self->btn_add, "clicked", G_CALLBACK(btnadd_clicked), self);