Skip to main content
gamedev.net
🔒 Locked

DirectShow

Started by zacharya Nov 26, 2003 at 5:28 AM 3 replies 250+ views
Original Post
zacharya
zacharya
I''m using direct show to play mp3 music as my background music. Do you know how to make it loop as long as my app runs? first I use RenderFile(....) then I Run() the file but how do I detect the file is finished? and one more thing if I stop() the file do I have to renderfile() again or just run() it again? thanks before
being young is a treasure that can''t be valued
joshboudreau
joshboudreau
Check out the Event Notifications for DirectShow (in the SDK docs its in DirectShow->About DirectShow->Event Notification..)

When you reach the end of the file/stream, you''ll get an "End of Stream" event of some sort. At that point you can simply Seek back to the beginning and Run(). (using IMediaSeeking and IMediaControl)

To your second question, If you stop the graph with IMediaControl::Stop() you don''t have to RenderFile() again. Simply Run() it again and it will resume from the stopped''s location. Stop will not seek back to the beginning of the stream, you will have to do that manually. So stop sorta acts like a Pause function. If you want to know the difference between Pause() and Stop() in IMediaControl, check the SDK docs. They behave in similar ways, but pause keeps buffering data, while stop completly stops data flow.

Hope that helps..
-- Josh BoudreauThis isn''t an office. It''s Hell with fluorescent lighting.
zacharya
zacharya
thanks joshboudreau for the help!
being young is a treasure that can''t be valued
zacharya
zacharya
well I found my self in trouble using ::SetPositions(...)
I tried using it like this

LONGLONG crPos;

pSeek->GetCurrentPosition(&crPos);

pSeek->SetPosition(&crPos,AM_SEEKING_AbsolutePositioning,
&llPos,AM_SEEKING_AbsolutePositioning);

I put 0 to llPos to make it seek to the beginning of segment (is it right?)

any help would be appreciated

thanks before
being young is a treasure that can''t be valued
joshboudreau
joshboudreau
This is the way I do it:


LONGLONG pos = 0;
pSeeking->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);


If you are still having trouble, maybe try looking at the HRESULT return values of the function calls, and post any errors you might get.

[edited by - joshboudreau on November 29, 2003 8:09:18 PM]
-- Josh BoudreauThis isn''t an office. It''s Hell with fluorescent lighting.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.