Re: WMP doesn't play a media on a thread



From: "sisimma"

Actually, my code has been running as you told.
The problem doesn't seem to relate timing. My code gives
enough time for WMP to run.

No, it doesn't.

Please give me another comment after review my code
snippet in more detail below

I did and the code you posted before was different. You now
have 2 threads:

[main]
CoInitializeEx()
CoCreateInstance()
....
put_URL()
create_thread1()
loop: mainfunction()
CoUninitialize()

[thread1]
CoCreateInstance()
....
put_URL()
loop: mainfunction()

thread1 is missing CoInitializeEx() (and CoUninitialize())
which means CoCreateInstance() is failing on thread1 and
only WMP on the main thread is playing. You are also not
releasing WMP when done. Your code should be:

[main]
CoInitializeEx()
create_thread1()
loop: mainfunction()
wait_for_thread1_to_end();
CoUninitialize()

[thread1]
CoInitializeEx()
CoCreateInstance()
....
put_URL()
wait_for_WMP_to_finish_playing_while_dispatching_messages()
release_WMP()
CoUninitialize()



--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


.


Loading