Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ouch, FoxPro let me down - duration = 0.00000
Message
From
01/01/2018 19:16:37
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01656859
Message ID:
01656878
Views:
80
this last code was just to show that wmp must load a media before begin to work and retrieve properties as duration.its not instantaneous.
the playstate event must be at least=10 to begin playing and retrieving properties.as i said its like ie navigate method.must wait to pass the transitionnings events.
see this link: https://msdn.microsoft.com/en-us/library/windows/desktop/dd564085(v=vs.85).aspx

Value State Description
0 Undefined Windows Media Player is in an undefined state.
1 Stopped Playback of the current media item is stopped.
2 Paused Playback of the current media item is paused. When a media item is paused, resuming playback begins from the same location.
3 Playing The current media item is playing.
4 ScanForward The current media item is fast forwarding.
5 ScanReverse The current media item is fast rewinding.
6 Buffering The current media item is getting additional data from the server.
7 Waiting Connection is established, but the server is not sending data. Waiting for session to begin.
8 MediaEnded Media item has completed playback.
9 Transitioning Preparing new media item.
10 Ready Ready to begin playing. >>>>>>>>>>>>>>>>>>at this step WMP can retrieve the duration
11 Reconnecting Reconnecting to stream.

i cite:"To retrieve the duration for files that are not in the user's library, you must wait for Windows Media Player to open the file; that is,
the current OpenState must equal MediaOpen. You can verify this by handling the Player.OpenStateChange event or by periodically checking the value of Player.openState."
inmy previous code i made a loop to wait the duration>0 to retrieve it.
in this case the method consumes too time for scanning a big media library as yours.
this problem is not specific to vfp you can read this :https://stackoverflow.com/questions/4411971/im-trying-to-read-a-video-duration-from-file-but-it-give-just-zeros-help-me

but have you tested the previous code i gave.it dont use the mediaplayer at all and retrieves all info for any file (particulary a media).
http://yousfi.over-blog.com/2015/03/playing-with-windows-mediaplayer.html code *12*
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform