rss
 
comment(s)

archives
J|F|M|A|M|J|J|A|S|O|N|D
(20##) 10 9 8 7 6 5 4 3 2 1 0 <
 
DesktopWeb FormText   bulletproofing PlayMediaExWed, 22 Feb 2006 04:29:44 GMT # 

the main problem i had with /mceVideoSearch is the PlayMediaEx call. the problem is that you cannot interrupt the call once it has been made. this sucks for videos that take a long time to buffer. if it takes 5 minutes for a video to buffer before playback, then the app is locked for 5 minutes. tried like 6 (or more) different ways to exit the call, and just could not make it stop. this needs to be fixed in Vista ... but i don't feel like waiting. there is an alternate approach for greedy calls like this ... defensive coding. don't call it unless you are sure it will work. so now the logic before a call to PlayMediaEx looks like this :

1) ping the video - just do an HttpWebRequest to the URL and check for an HTTPStatus of OK. meaning the video is still at the URL and has not been moved after the spider logged it.
2) media player - see if the MediaPlayer SDK can start playing the video. once it starts playing, then just immediately stop. this also allows the app to grab additional metadata (including file size) for the videos that the search service does not provide.
3) try downloading - start to download the video to get an estimate of how long it will take (based on file size above), then close the connection. if it will take a while to buffer, then prompt the user if they really want to wait that long. this isn't perfect because it gives false positives. i.e. some files start to play immediately even though it says it will take much longer. but at least it warns the user that they might be in for a long wait and gives them a chance to exit.
4) finally call PlayMediaEx ...