Archived

This topic is now archived and is closed to further replies.

how do u make a mp3 repeat...

This topic is 5589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

this is the replay function I am using in my dshow player


      
extern IGraphBuilder *g_pGraphBuilder = NULL;
extern IMediaControl *g_pMediaControl = NULL;
extern IMediaEventEx *g_pMediaEventEx = NULL;
extern IBaseFilter *g_pBackgroundMusic = NULL;
extern IMediaSeeking *g_pMediaSeeking = NULL;
extern IPin *pPin = NULL;
extern IMediaPosition *g_pMediaPosition = NULL;
extern REFTIME media_duration = 0;
extern REFTIME media_position = 0;

.
.
.

void Aurora_MP3::CheckMP3()
{
g_pMediaPosition->get_CurrentPosition(&media_position);
if(media_position == media_duration)
{
this->ReplayMP3();
}
}

void Aurora_MP3::ReplayMP3()
{
if (g_pMediaControl != NULL)
{
// Re-seek the graph to the beginning

LONGLONG llPos = 0;
g_pMediaSeeking->SetPositions(&llPos,
AM_SEEKING_AbsolutePositioning, &llPos,
AM_SEEKING_NoPositioning);

// Start the graph

g_pMediaControl->Run();
}
}


The check function is called from my main loop, with media_duration being set as soon as the mp3 is loaded as a global variable (aside, I really have to go through and fixing my nameing convention). After the duration is set, I enter my main loop then each frame I call check and if the current position in the mp3 is equal to the song length then it has finished and we can replay it (also need to add a function to load a new track, to allow users to either repeat a track or have a playlist). Might also need to change the == to an >- to catch the case where the loop isn't executed fast enough to catch each frame of the mp3.

This also works if you use an avi or any other dshow compatible format.

[edited by - knytestorme on August 28, 2002 1:36:09 PM]

Share this post


Link to post
Share on other sites
thanks man. so the only real way u can repeat mp3''s is to check if its finished every frame of the app. u cant do anything like in directX audio where u just SetRepeats() and it automatically repeats the music for u?

thanks for the code. it helped a lot

Share this post


Link to post
Share on other sites