Commit 639ef6a9 authored by François Grisez's avatar François Grisez

Add a function to MSMediaPlayer in order to enable looping feature

parent f3d2e423
......@@ -75,6 +75,16 @@ MS2_PUBLIC void * ms_media_player_get_window_id(const MSMediaPlayer *obj);
*/
MS2_PUBLIC void ms_media_player_set_eof_callback(MSMediaPlayer *obj, MSMediaPlayerEofCallback cb, void *user_data);
/**
* Require the player for playing the file again when the end is reached. Then,
* the player loops indefinitely until ms_media_player_stop() is called. That function
* can be called while the player is running.
* @param obj The MSMediaPlayer instance
* @param loop_interval_ms Time interval beetween two plays. If a negative value is
* set, the player does not loop.
*/
MS2_PUBLIC void ms_media_player_set_loop(MSMediaPlayer *obj, int loop_interval_ms);
/**
* Open a media file
* @param obj The player
......
......@@ -50,6 +50,7 @@ struct _MSMediaPlayer {
MSTicker *ticker;
MSFileFormat format;
bool_t is_open;
int loop_interval;
char *filename;
MSMediaPlayerEofCallback eof_cb;
void *user_data_cb;
......@@ -94,6 +95,7 @@ MSMediaPlayer *ms_media_player_new(MSFactory* factory, MSSndCard *snd_card, cons
obj->window_id = window_id;
}
obj->factory = factory;
obj->loop_interval = -1;
return obj;
}
......@@ -165,6 +167,7 @@ bool_t ms_media_player_open(MSMediaPlayer *obj, const char *filepath) {
return FALSE;
}
ms_filter_add_notify_callback(obj->player, _eof_filter_notify_cb, obj, TRUE);
ms_filter_call_method(obj->player, MS_PLAYER_SET_LOOP, &obj->loop_interval);
ms_ticker_attach(obj->ticker, obj->player);
obj->is_open = TRUE;
obj->filename = ms_strdup(filepath);
......@@ -259,6 +262,13 @@ void ms_media_player_set_eof_callback(MSMediaPlayer *obj, MSMediaPlayerEofCallba
ms_mutex_unlock(&obj->cb_access);
}
void ms_media_player_set_loop(MSMediaPlayer *obj, int loop_interval_ms) {
obj->loop_interval = loop_interval_ms;
if(obj->is_open) {
ms_filter_call_method(obj->player, MS_PLAYER_SET_LOOP, &obj->loop_interval);
}
}
bool_t ms_media_player_matroska_supported(void) {
#ifdef HAVE_MATROSKA
return TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment