how do u make a mp3 repeat...

Started by
1 comment, last by IFooBar 21 years, 7 months ago
hello how do u make an mp3 repeat itself in dshow. thakns
"We call em ''natural disasters'' but ''he'' (or she?) calls them memory leaks!!" Al **MY HQ**
[size=2]aliak.net
Advertisement
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]
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
[size=2]aliak.net

This topic is closed to new replies.

Advertisement