LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Video not showing in WMP ActiveX control

Trying to play an MP4 in Windows Media Player and I get a black control and WMP acts as if it is playing.  The MP4 does not have audio but other posts have suggested this is not affected by this issue.  I have tried all of the various solutions from other posts (converting to WMV, tuning off acceleration, ensuring WMP and refnums are closed properly) and nothing seems to work.

 

I've been able to get the video to work at times, but after it starts to flake out (black) it never seems to recover.  If I recreate the container it always works for at least one play.  It does not matter if I allow it to play all the way to the end or click on the control (and stop it via the event case) -- the error can occur either way.  

 

At times I have recieved an error (-2147417846) but this does not seem to be required in order to get the no-video effect (effect happens w/ or w/o the error).  I have not been able to track down details on the error but the 750ms delay seems to help with respect to occurence rate. 

 

When I get the black control, the background shows various other video effects both inside and outside of the ActiveX container.  See the "while_running.png" attachment.  After I stop the VI, the screen looks as in "after_stopping.png".  The "after stopping" look persists until I move the screen (and thereby force a redraw) even a little.

 

I do not recall installing any special CODECs, etc. and the videos all work fine repeatedely in stand-alone WMP.

 

Running:

  Win 7 (32) Home Premium SP1

  LV 2011 Pro

  WMP 12.0.7601.17514

 

 

Download All
0 Kudos
Message 1 of 10
(4,178 Views)

more information and a workaround but not complete understanding:

 

Recreated the issue on another machine (running LV 2011 Pro on XP w/ WMP 11.0.5...)

 

- Consistently saw the issue on the 2nd+ playing of the VI. 

- Could consistently see the video if I exited completely back to LV "getting started" screen

- Calling playMovie.vi as a subVI had the same effect -- the first time the sub was called the video showed up but not subsequent run of the parent VI.

- Called it multiple times as a subVI with 2sec dwell between each call and the first instance showed video but not the second, third.

- Made the subVI reentrant w/ "clone for each instance" and I get video every time.

- unchecked "reentrant" and added a "request deallocation" to the end of the subVI and issue returned (dealloc had no effect)

 

 

Seems something is getting set by the way I'm calling WMP that is not getting unset until I unload the VI completely from mem. Any ideas?

 

FWIW, today's experimentation used sample_mpeg2.m2v downloaded from http://support.apple.com/kb/ht1425

 

0 Kudos
Message 2 of 10
(4,150 Views)

Reentrancy workaround did not fix the original machine.

 

All video files have the issue.  Been using three files in particular (WMV, MP4, and M2V).  CODEC identifer says they're 3 diff CODECs so I'm guessing that's not it.

 

Back to square 1.   

0 Kudos
Message 3 of 10
(4,132 Views)

After fiddeling around quite some time, i didn't manage your VI to work correctly.

Therefore, i started to implement a new VI similar to yours. It worked until the part where i wanted to hook up to the Player state.

 

I found that using callbacks works as expected, so see attached example for guidance.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 10
(4,118 Views)

Zwired1,

 

I have been working with your code and I just want to make sure that I am understanding correctly what you would like to do. You don't just simply want to play a video in LabVIEW using the WMP ActiveX control, but rather you want to have several added features: autostarting the video, stopping the program when the video ends or if the user clicks on the video. Is there anything else you wanting for your end goal?

dK
0 Kudos
Message 5 of 10
(4,101 Views)

You are correctly understanding the function. 

 

I use this as a subVI.  I pass a path to it and want it to open the video and play.  If the video ends or if the user clicks on the control, the subVI front panel closes and returns control to the calling VI.

 

Thank you for having a look.  I will try your suggestion this afteroon.

0 Kudos
Message 6 of 10
(4,096 Views)

Zwired1,

 

So after playing around with your code, the only solution I was able to find was in changing the Window Appearance options in the VI properties. If you select "Allow user to resize window" and "Allow user to minimize window" and "Default" for Window Behavior, then the video should play every time. I know that you probably set these options for a reason, so I am trying to figure out why these options cause this error. Keeping the Window Appearance as Default returns the best results. 

dK
0 Kudos
Message 7 of 10
(4,067 Views)

@Norbert - your callback approach allowed the video to play repeatedly on both test machines, however...  Once you had me apparently past that hurdle I tried to figure out a way to keep the activeX control from resizing (autozoom to video files native size).  I searched through all prop and methods and tried everything I could think of but could not figure it out.  Fine, failing that, I tried to set the window size based on the resulting autosized activeX container with the WMP controls cropped ooutside the front panel window.  That broke the second playing of the video again. 

 

@Dan - thanks for continuing to look at this.  From my perspective, it feels like the bit that gets corrupted (or set-but-then-not-unset-on-exit-of-first-video) has to do with zoom/scaling or aspect ratio, if that helps.

 

 

Trying to make progress, and not finding any exposed WMP props for setting the player size in the ActiveX container, I tried loading the WMP inside a web page inside an ActiveX container per http://zone.ni.com/devzone/cda/epd/p/id/4540.  This gets me around the uncontrollable autosizing of the original VI (now cotrolled by the HTML layer) and also the no-video issue but introduces a new one -- clicking "stop" on the second-played video often results in a bad refnum passed to the "click" invoke inside the "stop" event case.  The VI stops but the video/audio keep going.   I thought it might be a reload-from-cache effect so I modified the "modifyHTML" subVI to save to a unique temp html file evey time and pass that path (as string) to the URL property in WMPBrowser -- no effect.   

 

0 Kudos
Message 8 of 10
(4,046 Views)

Zwired,

 

I have ran into this same issue, and I am trying to do the same thing. Using the web page seems to allow the video to play, but I am also confused as to how the "click" reference is already closed or bad at the Stop function. IT seems to work fine when the VI is on its own, but when you use it as a sub VI the issue pops up.  If I find a work around I will post it here.

 

 

Griff

0 Kudos
Message 9 of 10
(4,013 Views)

Browser-based solution seems to work if I put a 500ms dwell inbetween the "load URL" invoke and the "document" property immediately after.  See attached modification to the dev zone code originally at http://zone.ni.com/devzone/cda/epd/p/id/4540. 

 

I played around with reducing the dwell and for one video I could get consistent replays with as little as 100ms.  I then experimented with another video and had intermittent failures with any dwells less than 400ms.  Video file size of the second file was ~2x the first. 

 

I suspect the refnum generated by the IWebBrowser2 Document property is not valid on occasion because the video has not finished loading (it's trying to get a ref to something that doesn't quite exist yet) and the dwell gives it the extra time it needs.     

0 Kudos
Message 10 of 10
(4,000 Views)