Solved

Windows Media Player Component Crashes My Application

Posted on 2004-09-19
19
509 Views
Last Modified: 2012-06-27
Im making an Application which uses the Media Player Component..
now what if you play a Movie which inlcuded a Corrupted area in the movie ???
the Windows media Player simply crashes ..
and because my application hosts the Windows media player component it crashes along with the component ..
is there a way to fix this .. i mean to just make the windows media player component stop or terminate it without crashing my application .. because my application has many futures and tools in it.
Please let me know if you need further information ...
thank you in advance
OHDev
0
Comment
Question by:OHDev2004
  • 9
  • 7
  • 3
19 Comments
 
LVL 2

Expert Comment

by:lazesharp
Comment Utility
What version of the WMP control are you using? I've worked quite extensively with 6.4 but it differs vastly from the 9 and 10 WMP API so version is important.

As far as I know there is no built in functionality to catch the control failing to respond, infact this is something that i'm 99% certain would only be possible using the Windows API (if at all). I think this is going to be a problem that applies more to components in general that stop responding than just the Windows Media Player Control.

One more thing, does playing this corrupted file crash the vanilla Windows Media Player application? If so, what type of corruption is it? I've never seen WMP crash as a result of file corruption.
0
 
LVL 7

Author Comment

by:OHDev2004
Comment Utility
LOL ... the version doesn't matter because the case is the corrupted Video file ..
which makes every version crack .. i've tested it with 6.4 and 9 and they do the same ..
Well i have a corrupted AVI cartoon (Finding Nemo) at the moment and i encouter sometimes other corrupted movie files..
some other video players don't crash .. as if they know that this area is corrupted so they stop playing ..

yes it's something i should hook or something using API to prevent the whole Application from crashing ..it's a pain to seperate the Media player from the Mother application and make it in a seperate small application ..
so im willing for a way to catch the crash and simply RESUME NEXT :P LOL
Thank you
OHDev
0
 
LVL 7

Author Comment

by:OHDev2004
Comment Utility
This will be a Cyber cafe Program ... that means the application is going to be the only application visible to the user .. where he can open instances of Internet Explorer/Open Programs/Open Games/Play Mp3/Video/RM ...
so now i think you know what i meant .. i tried to make the application the All in one to prevent the users from playing and messing with the Computer ...
OHDev
0
 
LVL 2

Assisted Solution

by:lazesharp
lazesharp earned 200 total points
Comment Utility
I understand what you're saying, what i meant was, have you tried just running the movie in Windows Media Player itself and seeing if that crashes? Since the control is so tightly related to it I should think they'll behave in a similar fashion.

As for noticing the crash, detecting problems with external programs has never been easy, just look at Windows itself, the number of strange happenings that go on when something stops working as it should shows just how hard it can be to catch programs failing to respond even when given such low level access to the operating system.

As a work around you could think of writing a small helper application that uses the DDE Server/Client API to regularly query your program for it's status, and when a message or two fail to get sent, it could kill the process and automatically restart the program. The user would see something odd, but shouldn't give them any access to the program. As far as code is concerned, your best bet is to look up the API calls on MSDN (http://msdn.microsoft.com/library/) and convert the C style declarations to VB yourself (it's fairly straightforward). The hard part will be trying to locate the APIs you need to use and figuring out exactly how to use them.

For an updated API Viewer tool (includes all the Win2k and WinXP specific APIs), give this a go: http://www.activevb.de/rubriken/apiviewer/index-apiviewereng.html#anchor1

Sorry I can't be much more help, but there's a starting point to try to solve this yourself if no one else can give you a full solution.
0
 
LVL 7

Author Comment

by:OHDev2004
Comment Utility
Lol ... thank you very much for trying to help me .. it's really appreciated!

about the corruption yes .. it crashes the independent media player too .. :( .. LOL
the way to prevent this is hooking into my application and listen to crash messages or something like that and then prevent crashing .. but i don't have a clue where to start ....
i worked with hooking before butit was with mouse/Keyboard hooking/And Custom window messages  ..
thank you very much for ur help !
OHDev
0
 
LVL 7

Expert Comment

by:Burbble
Comment Utility
Just my two cents:

It may be the actual codec that is crashing, and thereby bringing the Windows Media Player component down with it. I have experienced this problem a lot when playing back corrupted AVIs encoded with XVID. The corrupted data could be causing something as simple as a divide by zero error, which crashes everything associated with it.

If you aren't able to trap the error, then you might check if there is a newer (hopefully more resistant) version of the codec that doesn't experience the problem.

-Burbble
0
 
LVL 7

Author Comment

by:OHDev2004
Comment Utility
hey Burbble
you are right ... it is the codec .. and yes it almost happens 90% with Divx coded movies ... so if a corrupted frame occurs it brings down the whole thing ... i was just asking if there's a way to prevent this :P
you know some media players like Divx player and Koala player don't crash ??? strange huh .. they managed to prevent errors from showing ..
i even thought about playing the movie my self .. like extracting and viewing the frames my self ... but i don't know how this is done at all :) LOL

OHDev
0
 
LVL 7

Expert Comment

by:Burbble
Comment Utility
Now that you mention it, I remembered something: A corrupted video I once acquired played fine in DivX Player and a few others, but crashed in Windows Media Player. I have *no* idea why... A theory: Windows Media Player seems to always download codecs when you start playing a movie or MP3. Perhaps it is downloading some alternative "Microsoft" codecs that are poorly made?

You could check here for reading the AVIs directly, but I don't think there is any documentation on how to retrieve an audio stream, which may make it a futile effort in the long run... http://www.shrinkwrapvb.com/avihelp/avihelp.htm

By the way, what is the error message exactly?

-Burbble
0
 
LVL 7

Expert Comment

by:Burbble
Comment Utility
lol, typical... Of course, Microsoft blames the problem on everyone else:

-----
1.13  Why does the Player keep crashing?
Windows Media Player interacts with many system components, including drivers, codecs, and DirectShow® filters. It is possible that the Player is not responding because of a faulty or incompatible component from another provider, such as a codec pack. (Examples include the DivXNetworks Nimo, Tsunami, and K-Lite codec packs, and the SoftRom.Net ACE Mega, and All in 1 codec packs.) Incompatibilities are known to exist with some of the components in the codec packs. The incompatibilities can cause serious playback issues in Windows Media Player and other players, can lead to system corruption, and can make it difficult for Microsoft Product Support Services to diagnose and troubleshoot playback issues. For more information about resolving this problem, see question 3.8.

To protect the security of your computer, be sure to only download programs, codec packs, and other items from sources that you trust. To learn more about security, see the Windows Media Player security statement.
-----

-Burbble
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 7

Author Comment

by:OHDev2004
Comment Utility
lol ...as usual ..
nevermind ... thank you anyway for your help..

hmmm .. i really don't know what to do now :( ... it's a discusting bug...
well.... i think the only solution which still needs a solution is :P

"the way to prevent this is hooking into my application and listen to crash messages or something like that and then prevent crashing .. but i don't have a clue where to start ...."
OHDev
0
 
LVL 2

Expert Comment

by:lazesharp
Comment Utility
Regarding that last post of what Microsoft says, DO NOT install Codec packs (especially the K-Lite or Nimo packs), they have and have always had known issues with Windows XP. Download the separate codecs, here are the most common:

DivX: www.divx.com
XviD: (this is a stable windows binary): http://koepi.roeder.goe.net/xvid.shtml
AC3Filter (used for decoding AC3 audio in some better quality movie rips): ac3filter.sourceforge.net

These 3 codecs should play just about any well ripped movie, i know it's a bit of a taboo subject, but since you are talking about watching pirated movies, the "professional" rips tend to all be in XviD with either an MP3 or AC3 soundtrack these days, and before that it was DivX with an MP3 soundtrack, so these should cover anything worth watching really.

Again, i cannot stress enough how important it is that you uninstall any and all codec packs you have, while being a timesaver they're often badly thrown together and include either conflicting codecs or more commonly, unstable versions of codecs that have been hacked about by the pack compiler. Use the officially released codec builds i've listed above, it will save you so much trouble in the future.

And FYI: i've never come across a single DivX or XviD encoded movie that has caused WMP to crash or do anything abnormal, the worst i've had is no picture when i forgot to install XviD after a format.

Hope this helps.
0
 
LVL 7

Author Comment

by:OHDev2004
Comment Utility
thank you first of all :)

but it's not the Codec Isue afterall because this sometimes happens with any format if it is corrupted even older formats before the appearing of Divx .. yes it happens most with divx ripped videos because they are ripped mostly on a machine which is not that fast so some frames may get corrupted during the ripping or converting ..
but im talking about a general isue .. which is to prevent the app or Media player within my program to crash the whole program ..
OHDev
0
 
LVL 7

Accepted Solution

by:
Burbble earned 300 total points
Comment Utility
I'm not here to start an argument, just stating what I've learned from my experiences. I am a big fan of the Nimo Codec Pack -- provided that you use it cautiously, and know what you are installing. A few of the included filters/codecs are HIGHLY unstable, and can easily cause problems, but you should by no means write of the entire thing simply becaues of this fact. You have to know what to unselect when installing, which kind of defeats the "convenience" factor of a Codec Pack.
The codecs that I have installed are flawless on NON-corrupted movie files, but tend to be unstable when playing files with missing/damaged sections (i.e., an incomplete file from eMule). Albiet, by no means "highly" unstable, and the possibility of a software crash depends on the type of encoding, the disarray of the AVI file, and if you tend to Fast Forward/Rewind/Pause it frequently.

Anyway, back on topic... :)

As a sort of rudimentary "fix", you could write a secondary program that constantly monitors the process list, and if your program isn't detected, it executes it (or restarts the computer).

Is your program defined as the default Shell (such as the shell=Explorer.exe in System.ini)?

I can provide sample code if you like the idea.

-Burbble
0
 
LVL 7

Expert Comment

by:Burbble
Comment Utility
Whoops, didn't see your post there. I guess if you decide that it's impossible or impractical to develop a way to trap the errors, then the best alternative would be to just let the error take its course, and then execute the program again.

-Burbble
0
 
LVL 7

Author Comment

by:OHDev2004
Comment Utility
yes .. but how :) that's the big question .... i think it's possible with API Hooking ...

nevermind .. i never meant to be negative to you and to lazesharp .. i really didn't mean that ... :)
it's just something regarding the codecs ... im looking for a work arround to simply ignore the crash and Resume Next :)

sorry again for boring you two :)
OHDev
0
 
LVL 7

Expert Comment

by:Burbble
Comment Utility
Oh, you could also write your Media Player as a separate EXE. Your main program launches that, and if it crashes, it doesn't really matter -- the user just starts it again from within your program.

I haven't got a clue about API hooking, sorry -- I guess you could say that I'm more inclined to work around certain problems than to fix them :)

-Burbble
0
 
LVL 7

Author Comment

by:OHDev2004
Comment Utility
thanks a Lot .. ..
i do the same here :) ..
i thought about doing this  but i was keeping it as the last solution if there isn't any other way ... and i think there's no escape from it now :) ..
i was going to make it a seperate EXE .. and make that exe pass it's Position every second or every 5 seconds .. and if it crashes .. that means without notifying the parent application the parent application will launch it again and play  the file after the position it stopped at with 5 seconds at least to prevent coming on the same corrupted part ..

thanks a lot ..
I'll keep this question up for a Day or two incase someone comes up with a Hooking Idea :)
Thank you very much
OHDev
0
 
LVL 7

Expert Comment

by:Burbble
Comment Utility
Thanks for the points, sorry I couldn't help more :/

-Burbble
0
 
LVL 7

Author Comment

by:OHDev2004
Comment Utility
No man :) thank you for your Help
I really appreciate it ... even if the talking didn't comeout with the solution i was thinking of but it was a very good talking and you all expressed some good ideas ... although i didn't start to Implement that Idea :) LOL

thank you again for ur Help :) and sorry for the C grade :(
OHDev
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now