Contents tagged with Sound
This entry may surprise some people I know that are reading the main feed every day - I didn't tell them I would start a blog... For everybody else some quick info about me: I'm 34 years old, started programming in 1983 on a TRS-80 Color Computer and got my first PC in 1989. I live in Bonn, Germany, working as a software developer for a local company. In my spare time I enjoy writing tools and macros, and - in many iterations over the last years, using different languages/technologies - a kind of DJ'ing software for sports events like basketball games. Currently I'm doing a complete rewrite in C#, using the windows media player 9 SDK.
So far, my experiences using the media player object, its properties, methods and events have been very good. But yesterday I ran into something rather strange.
Say you open a sound file like this:
and now you want to know the duration
but dDuration is 0. If you play the sound file, currentMedia.duration contains the correct value. But you want the duration before starting playback. Ok, next try:
IWMPMedia objMedia = objPlayer.newMedia(filename);<br>objPlayer.currentMedia=objMedia<br>double dDuration=objPlayer.currentMedia.duration;<br>
Again, dDuration is 0. Now try this:
IWMPMedia objMedia = objPlayer.newMedia(filename);<br>double dDummy=objMedia.duration;<br>objPlayer.currentMedia=objMedia<br>double dDuration=objPlayer.currentMedia.duration;<br>
And... dDuration contains the correct value!
Took me some time to figure out that one...