Add support for repeat one audio
This commit is contained in:
parent
6858dc3b38
commit
febde53ced
|
@ -389,16 +389,43 @@ static void media_play_ended_handler(MyMediaPlayer *player)
|
|||
{
|
||||
// Play a list of music once
|
||||
case PlayMode::List_Once:
|
||||
// Only play music when current audio is not the end of the audio list
|
||||
if (my_media_player_get_current_index(player) <
|
||||
my_media_player_get_n_audios(player) - 1)
|
||||
{
|
||||
// use the function for play next button to load next audio
|
||||
btnnext_clicked(NULL, player);
|
||||
|
||||
// Get media stream to control
|
||||
stream = gtk_video_get_media_stream(GTK_VIDEO(
|
||||
my_media_player_get_video_widget(player)));
|
||||
|
||||
// Play media stream associated with media file
|
||||
gtk_media_stream_play(stream);
|
||||
}
|
||||
break;
|
||||
case PlayMode::List_Repeat:
|
||||
// In List Repeat Mode, use the function for play next button
|
||||
btnnext_clicked(NULL, player);
|
||||
|
||||
// Get Media stream to control
|
||||
stream = gtk_video_get_media_stream(GTK_VIDEO(
|
||||
my_media_player_get_video_widget(player)));
|
||||
|
||||
// Play media stream associated with media file
|
||||
gtk_media_stream_play(stream);
|
||||
break;
|
||||
case PlayMode::List_Shuffle:
|
||||
break;
|
||||
case PlayMode::One_Repeat:
|
||||
|
||||
// Get media stream to control
|
||||
stream = gtk_video_get_media_stream(GTK_VIDEO(
|
||||
my_media_player_get_video_widget(player)));
|
||||
|
||||
// Play media stream associated with media file
|
||||
gtk_media_stream_play(stream);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -335,6 +335,18 @@ PlayMode my_media_player_get_play_mode(MyMediaPlayer *self)
|
|||
return self->current_play_mode;
|
||||
}
|
||||
|
||||
guint my_media_player_get_current_index(MyMediaPlayer *self)
|
||||
{
|
||||
// Get the index of current playing audio
|
||||
return self->current_audio_index;
|
||||
}
|
||||
|
||||
guint my_media_player_get_n_audios(MyMediaPlayer *self)
|
||||
{
|
||||
// Get the number of audios in the list
|
||||
return self->n_items;
|
||||
}
|
||||
|
||||
static void my_media_player_expander_activate(GtkExpander *self, MyMediaPlayer *player)
|
||||
{
|
||||
if (!gtk_expander_get_expanded(self))
|
||||
|
@ -421,7 +433,7 @@ static void btnpriv_clicked(GtkButton *self, MyMediaPlayer *player)
|
|||
|
||||
// Update selected item
|
||||
gtk_single_selection_set_selected(player->music_selection,
|
||||
player->current_audio_index);
|
||||
player->current_audio_index);
|
||||
}
|
||||
|
||||
// Play next music
|
||||
|
@ -456,7 +468,7 @@ void btnnext_clicked(GtkButton *self, MyMediaPlayer *player)
|
|||
|
||||
// Update selected item
|
||||
gtk_single_selection_set_selected(player->music_selection,
|
||||
player->current_audio_index);
|
||||
player->current_audio_index);
|
||||
}
|
||||
|
||||
// Stop current music
|
||||
|
|
|
@ -24,6 +24,10 @@ PlayMode my_media_player_get_play_mode(MyMediaPlayer *self);
|
|||
|
||||
char *my_media_player_get_filename(MyMediaPlayer *self);
|
||||
|
||||
guint my_media_player_get_current_index(MyMediaPlayer *self);
|
||||
|
||||
guint my_media_player_get_n_audios(MyMediaPlayer *self);
|
||||
|
||||
void btnnext_clicked(GtkButton *self, MyMediaPlayer *player);
|
||||
|
||||
MyMediaPlayer *my_media_player_new(GtkApplication *app);
|
||||
|
|
Loading…
Reference in New Issue