Example Code

Play Files in Windows Media Player using ActiveX in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW
  • Other

Code and Documents

Attachment

Download All

Overview
This example VI opens Windows Media Player on your computer and plays a selected file.

 


Description
You can use any video file that is supported by Windows Media Player (.mpa, .mp2, .mp3, .avi, .wma, etc..). The Strip Path VI finds the location of the current VI. This is particularly useful if the example file is saved to this folder as well. If not, then the video file path can be referenced directly into the constant. The Build Path VI adds the current folder filepath to the video name so that the full filepath can be used to play the video. There are many Windows Media Player (WMP) ActiveX classes that can manipulate it in a number of ways. 

 


Requirements

  • LabVIEW 2012 (or compatible)
  • Windows Media Player

 


Steps to Implement or Execute Code

  1. Unzip the attached folder to your computer
  2. Open the VI "Windows Media Player.vi"
  3. Run the program

 

 

Additional Information or References
VI Block Diagram

BD.PNG

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
LV_Pro
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast
on

Not all of us have moved on to 8.6

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



wprice
Member
Member
on

Good example! I tried it on LV2009 and it works, however the stretchToFit method does not work so it does not resize the player when the main window is resized.

- WinXP, WMP 10.0

nymoon
Member
Member
on

It can meet basic needs,so good.

by the first ,LabView is so strong!
Marinica
Member
Member
on

How can you build this from scratch? I placed "Automation Open" and "property node", but I was not able to place the reference to "WindowsMediaPlayer". I tried using "create control", but I was not able to generate similar controls. Downloading it from your site, I was able to run it very well, I'm working with LabVIEW13.

Thank you.

0Forest0
Member
Member
on

Thank you very mutch. I think it's very  hard to find the ActiveX reference in that long list whithout search button.

LocalVariable44
Member
Member
on

Thank you so much!