Play Video
By Richard Rost
4 years ago
Play a Video File in a Access using WMP Control
In this Microsoft Access tutorial, I'm going to show you how to play a video or audio file inside your database using the Windows Media Player ActiveX control.
Laci from Zachary, Louisiana (a Platinum Member) asks: I know you can display pictures, but is there any way to play videos inside an Access database? We make demo videos for a lot of our products, and it would be nice and handy if we could list them along with our products and possibly view them there as well.
Members
Members will learn how to create a playlist to select videos from, we'll learn how to resize the player in the form window, we'll learn how to launch the videos in whatever the installed (external) video player is on your system, and we'll see how to use the VLC Media Player ActiveX control which is much better than Windows Media Player.
Silver Members and up get access to view Extended Cut videos, when available. Gold Members can download the files from class plus get access to the Code Vault. If you're not a member, Join Today!
Recommended Course
Links
Keywords
access 2016, access 2019, access 2021, access 365, microsoft access, ms access, ms access tutorial, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #learn, #lesson, #training, #database, windows media player control ms access, windowsmediaplayer control, Playing Window media control in Access, Access and Windows Media Player, VBA Windows Media Player in Access, Play video in an access form using windows media player, Using Windows Media Player in Access Form, VLC media player, videolan, ocx, activex, followhyperlink, height, width, url, insideheight, insidewidth
Subscribe to Play Video
Get notifications when this page is updated
Intro
In this video, I will show you how to play video and audio files in Microsoft Access by adding the Windows Media Player ActiveX control to your forms. We will walk through the steps to insert the control, set it up with a file name text box and play button, and use a single line of VBA code to play your video files directly in your Access database. I will also discuss some warnings about ActiveX compatibility and tips for using Windows Media Player in modern versions of Windows.
Transcript
Welcome to another TechHelp video brought to you by AccessLearningZone.com. I am your instructor, Richard Rost.
In today's video, I'm going to show you how to play a video or audio file in Microsoft Access using the Windows Media Player ActiveX control.
Today's question comes from Lacey in Zachary, Louisiana, one of my Platinum members. Lacey says, I know you can display pictures, but is there any way to play videos inside of an Access database? We make demo videos for a lot of our products, and it would be nice and handy if we could list them along with our products and possibly view them in there as well.
Well, Lacey, yes, Windows comes with something called Windows Media Player. Now, Microsoft has deprecated a lot of Windows Media Player stuff, but there's still an ActiveX control that comes with Microsoft Access. I generally don't like to use it because it is a little clunky, but it should do the job if you just want to view videos inside your database, like product demos and stuff like that.
Now, I can't promise how much longer the Windows Media Player will be shipped with Windows or Office. It's currently 2022, and it's in my system, and my machine is relatively new. But if you're watching this two or three years down the line, I can't guarantee they'll still have it. Let me show you what is in there right now so you can use it if you want to. It's not that hard to set up.
Before we get started, if you've never done any VBA programming before, go watch this video, my Intro to VBA. It's 20 minutes long, teaches all the basics, everything you need to know to get started with VBA. We literally only need one line of code in this database to play a video, but you need to know where to put it. Watch Intro to VBA so you know all the background stuff and where I show you how to put things.
Here we go.
Here we are in my TechHelp free template. That's a free database. You can grab a copy from my website if you want to, but you don't have to. You can do this to any database you want.
Let's go into design view. I'm just going to use my main menu here, and I'm going to pretty much just delete all this stuff. I shouldn't delete my logo, but I will delete all this stuff for now, which means we can delete all the code out of it too. We don't need all this stuff in here. Goodbye.
For those of you who don't know, if you haven't watched my previous videos, the code behind the form can be found right over here too. See this little guy right there that says View Code? It's on the Form Design tab. Slide over here. If your window is larger, it'll look like that - View Code. I put it up in my Quick Launch toolbar so I can quickly get to it because I jump to it a lot.
The first thing we have to do is add the ActiveX control, which is in our ActiveX controls up here. Open up your toolbox, go to ActiveX controls, and click on that. ActiveX controls are cool, but they're not part of Access. A lot of them are distributed with Windows and Microsoft Office. For example, you have the Microsoft Forms stuff in there. You have Outlook stuff if you have Outlook on your machine. You've got all kinds of cool stuff. I've done videos before on the tree view and on the slider.
The problem is that if you've got a bunch of different users with different versions of Access, these controls might not be the same on everybody's machines. Only use this stuff if you're absolutely sure that everyone using your database has the exact same version of Windows and Office on their machines. If your workplace does that, then you're okay. If you're planning on doing this on your own and selling it or distributing it to other people, you have to make sure that they have the same version too, or it might not work.
Scroll all the way down to the bottom and find Windows Media Player right there. As I said earlier, Windows Media Player has kind of been deprecated. Microsoft has a new version of their video player that came out with Windows 10 and in 11, but Windows Media Player is still on most machines. I'm just doing a quick look on Wikipedia here. It looks like, as of October 2021, Windows Media Player is still included as a Windows component, so you can still use it in your applications. As of 2021, it's going to still use a new media player application, but the legacy Windows Media Player will continue to be included with Windows 11.
So you're good for now. But don't be surprised if Windows Media Player is completely deprecated in a little while. Like I said, it's currently 2022, so we can get away with this right now.
Pick Windows Media Player, and there's your component. A couple of things. First of all, you may be tempted to resize this. Don't. It's a little bit of a bug. If you try to resize this thing, it usually snaps back to its current size. You can move it around, put it wherever you want, but leave it that size. I will show in the extended cut how we can resize this thing with code, and that will work. For the simple version, that's the size player you're getting. I'm sorry. It's a bug. Watch, I'll show you.
If we size this over here and then we do one of these jobs, like this, it looks like it resized just fine. Save it, close it, open it back up again and look at that. See, it resized itself. It's a bug. Leave it at whatever size it is in here. In fact, I'm going to slide this down just a little bit because we're going to put a text box up here with our file name in it.
First, let's give this guy a good name. I don't like WindowsMediaPlayer0. Let's change it to just WMP. Much shorter, much easier. Don't change some of these other things like Windows Media Player as the OLE class. Leave that stuff alone. You can double click on this to get some other options, like volume settings and stuff. You can play with all these settings on your own time. There are some different options in here. If you Google search Windows Media Player ActiveX Control, you will find some other code and stuff online. I could very easily do a full class on this, an hour long, but I'm not going to.
Let's put a text box up here that will put our file name in. We'll call this guy FileName. We'll make it about this big. I'm going to set a default value. I've got my database running here off of my desktop. I'll grab one of my other videos. This is null.mp4. It's a video I released, I think, last week about null values, a couple of weeks ago. If you double click on this, you'll see it play:
Welcome to another fast tips video brought to you by Access Learning...
Good enough. I'm going to play it in the current folder, whatever my database's current folder is, so I can use my CurrentProject.Path trick that I showed you in a previous video as well. I'm going to set the default value to this. Default value is going to be null.mp4. That's my default video. You could change it if you want to.
I'm going to put a button right next to it. Cancel the wizard, and this will be my play button. So you change the file name here, and then you'll hit play. Let's name this guy my play button, PlayBPN. Now I can resize this.
Right click, build event. Here's the one line of code that we need. I'm going to type it in, and then I'll explain it:
WMP.URL = CurrentProject.Path & "\\" & FileName
That's it.
What does this all mean? WMP is the name of our control - our Windows Media Player control. .URL stands for uniform resource locator. It's generally used for web addresses like 599CD.com or Microsoft.com. But in this particular case, it can be either a web page address that has a valid video at it, or a local file name that's a valid video. I'm going to be using a local file name, but I could very easily play something off my website here too.
We're going to set that URL equal to the file name, which is the name of the file that we specified in this text box. I'm adding to it the CurrentProject.Path and a backslash. This is whatever folder the database is in. In my case, the desktop. So this will get replaced with C:\\Users\\Richard\\Desktopull.mp4. See how that works? You could very easily hard code that yourself if you want to.
In the extended cut, I'm going to show you how to make a playlist where you can put a bunch of videos in a list box. Save it, close it, open it up, and hit play.
Welcome to another fast tips video brought to you by AccessLearningZone.com. I am your instructor, Richard...
Your basic controls.
One thing you'll notice here is that it's not very good with keyframes. A keyframe is like every 10 or 20 frames of the video is a keyframe where the whole image gets redrawn. Usually the video player just puts what has changed. Sometimes I've noticed Windows Media Player, especially when you pause it, sometimes it loses it. You skip ahead, it does a lot of math. My job is just to date the video refresh. But it's not bad.
Check it out.
I'm a tiny video player. Welcome to another fast... I am your instructor...
You stop it, you want to change it, you change the file name up here.
If you want to resize this guy, I'm going to show you how to do that in the extended cut with some code. As we resize the form, it'll resize the video player to fill that space. It's just a bug in the design view where it always snaps back to the size. If you know of a solution for that, please post it down below. I messed with it for a while. I couldn't get it to stick. I think that's why I stopped using Windows Media Player a while ago.
That's it. That's how you make a Windows Media Player inside your Access database.
On the extended cut, I'm going to show you how to make a playlist right over here. You can make a table that's got the titles in it with the file names. They don't have to be in the current database folder. You click on it, it's going to launch over here. We'll do the resize of the form - when you resize your form, your player will resize as well.
I'm going to show you how to launch these externally. In other words, if you don't want to put the video player inside of Access, which is how I actually like to do it, we'll just take the playlist and we'll make a button down there that's 'Play'. It will launch whatever your default video player is on your system. It doesn't matter. You don't need any components. You don't need anything inside your database. You don't need a specific video player installed on your machine.
I prefer this guy, the VLC Media Player plugin. It's my video player of choice. Been using it for years. I will show you how to use this both externally and with the plugin too. When you install the VLC Media Player, it also drops a plugin that you can use in Access. This will all be covered in the extended cut.
If you want to learn how to do video playing inside of Access, this will be the video for you. Silver members and up get access to all of my extended cut videos. We're approaching 300 of them now - it's a lot of stuff to watch.
Gold members, you can download these databases, and you get access to my code vault and a lot of other cool perks. Plus, every member, Silver and up, gets some free classes. So stop by my website if you're a member and set up your account.
That's it. I hope you learned something today, and we'll see you next time.
How do you become a member? Click on the Join button below the video. After you click the Join button, you'll see a list of all the different membership levels that are available, each with its own special perks.
Silver members and up will get access to all of my extended cut TechHelp videos, one free beginner class each month, and more.
Gold members get access to download all of the sample databases that I build in my TechHelp videos, plus my code vault where I keep tons of different functions that I use. You'll also get a higher priority if you decide to submit any TechHelp questions to me, and you'll get one free expert class each month after you've finished the beginner series.
Platinum members get all the previous perks plus even higher priority for TechHelp questions, access to all of my full beginner courses for every subject, and one free developer class each month after you've finished the expert classes. These are the full length courses found on my website, not just for Access. I also teach Word, Excel, Visual Basic, and lots more.
You can now become a Diamond sponsor and have your name or company name listed on a sponsors page that will be shown in each video as long as you're a sponsor. You'll get a shout out in the video and a link to your website or product in the text below the video and on my website.
But don't worry, these free TechHelp videos are going to keep coming. As long as you keep watching them, I'll keep making more, and they'll always be free.
Quiz
Q1. What is the main purpose of the Windows Media Player ActiveX control in Microsoft Access as demonstrated in the video? A. To play video or audio files inside an Access database form B. To create new video files for use in Access C. To display animated GIFs in reports D. To convert Access data to multimedia content
Q2. What is an important consideration when using ActiveX controls like Windows Media Player in Access databases? A. They work on all platforms including Mac and Web B. All users must have the same versions of Windows and Office C. They automatically update with every Windows release D. They can be used without any version compatibility concerns
Q3. According to the video, what may cause the Windows Media Player ActiveX control to be unavailable in the future? A. It is not supported on 32-bit systems B. Microsoft may eventually remove it from Windows and Office C. It conflicts with Microsoft Edge browser D. It is only available on Windows Server editions
Q4. Why should you avoid resizing the Windows Media Player ActiveX control in form design view? A. It cannot be resized at all, ever B. It is always fixed to the top left of the form C. It will usually snap back to its default size due to a bug D. Resizing deletes any video files associated with it
Q5. In the VBA code provided (WMP.URL = CurrentProject.Path & "\\\\" & FileName), what does 'CurrentProject.Path' represent? A. The root directory of the C: drive B. The folder where the Access database is currently stored C. The default folder for Windows Media Player D. The Temp directory in Windows
Q6. What is the recommended way to specify the video file to play in this setup? A. Hard code the file location in VBA only B. Enter the file name into a text box on the form C. Always use a file dialog to select a file D. Type the video URL directly into the Access VBA editor
Q7. According to the video, what happens if you save and reopen a form after resizing the media player control in design view? A. The control remains at the new size B. The control disappears entirely C. The control snaps back to its original size D. The form will not open
Q8. What limitation is mentioned about distributing Access databases that use ActiveX controls? A. The controls do not work on laptops B. The controls can only be used by administrators C. All target users need the same ActiveX components installed D. Access automatically handles missing controls
Q9. What is the easiest way to play a different video file using this method? A. Modify the VBA code every time B. Replace the ActiveX control with a new one C. Change the text in the file name text box and press Play D. Recompile the database from scratch
Q10. What additional functionality is mentioned as being covered in the extended cut video? A. Converting videos to different formats B. Creating a playlist and automatically resizing the video player with the form C. Streaming videos directly from YouTube D. Encrypting video files in Access
Answers: 1-A; 2-B; 3-B; 4-C; 5-B; 6-B; 7-C; 8-C; 9-C; 10-B
DISCLAIMER: Quiz questions are AI generated. If you find any that are wrong, don't make sense, or aren't related to the video topic at hand, then please post a comment and let me know. Thanks.
Summary
Today's video from Access Learning Zone focuses on how to play video or audio files directly within a Microsoft Access database using the Windows Media Player ActiveX control. This particular topic was inspired by a question about displaying demo videos for products inside an Access database, making it easier to manage and view multimedia content alongside product data.
Windows systems typically include Windows Media Player, and although it has been deprecated by Microsoft, the ActiveX control is still available in Access as of 2022. While I generally avoid relying too much on these controls due to compatibility issues and their somewhat clunky behavior, they can be useful if you simply want to play videos within your database, such as product demos.
One important thing to note is that the continued presence of Windows Media Player in future versions of Windows is uncertain. At the moment, both Windows 10 and 11 still include it, albeit as a legacy component. However, if you need to display video content in Access right now, this method works and is relatively straightforward to set up.
If you are new to VBA programming, I recommend watching my Intro to VBA video, which covers the basics and shows you where to place your code within Access. In this tutorial, you will only need one line of code to play your video, but having a fundamental understanding of VBA structure is essential.
To begin, I use my free TechHelp template database, but you are welcome to use any database you have. After opening your form in design view, clear out any existing controls that are not needed for this demonstration. Your next step is to add the Windows Media Player ActiveX control to your form. This control is accessible through the toolbox under ActiveX controls.
ActiveX controls, while useful, are not inherently part of Access. They come from Windows or Office installations and can vary depending on what software is present on a user's machine. Therefore, only rely on them if all users of your database have consistent versions of Windows and Office. Mismatched environments can lead to compatibility problems.
Once you have located and added the Windows Media Player control, you may notice some quirks. For example, trying to resize the control in design view often causes it to revert to its default size. You can reposition it, but resizing in design view is unreliable. In today's extended cut, I'll demonstrate how to work around this using VBA code so the control resizes as you adjust the form.
Rename your Windows Media Player control to something manageable, like WMP, for simplicity. Avoid changing the OLE class name or other component details. If you like, you can adjust settings such as volume or experiment with other options available in the control's properties.
Add a text box to your form where users can specify the file name of the video they wish to play. For demonstration, I use a sample video file, null.mp4, and set it as the default value. This way, there is always a video ready to play when testing.
Next, place a button next to the text box. When pressed, this button will play the file whose name appears in the text box. Name the button PlayBtn for clarity.
The code for this operation is quite simple. Assign the URL property of the WMP control to the file path, which combines the current project's directory with the file name given in the text box. This approach means the video must reside in the same folder as your database, but you could hardcode a different path if needed. You may also use a web address in place of a local file if your video is hosted online.
After saving and reopening your form, entering a valid video file name and pressing Play will launch the video right within the form using the standard controls provided by Windows Media Player. While playback is generally smooth, there can be occasional issues with keyframes or video refresh, but overall the functionality is sufficient for basic tasks.
If you want to change the video, simply update the file name in the text box and click Play again. For resizing the Windows Media Player control, I will cover a solution using VBA code in the extended cut. This allows the player to dynamically adjust its size as the form resizes, overcoming the design-time limitation.
In the extended cut of this lesson, I will also show how to create a video playlist using a table and list box, enabling users to select and play different videos from a list. Additionally, I will demonstrate how to launch videos externally, playing them in the system's default media player instead of embedding them in Access. This method eliminates the need for ActiveX controls and is often more reliable. I recommend VLC Media Player as a great option, and I will show how to use its plugin within Access for even greater flexibility.
If you're interested in implementing video playback in Access, this tutorial will provide a solid starting point, and the extended cut goes much deeper into advanced features like playlists, resizing, and integration with external media players and plugins.
Access Learning Zone members at the Silver level and above can watch all extended cut videos. Gold members can download my sample databases and access my code vault, which contains many functions I use in my work. All Silver and Gold members also get free classes each month, and Platinum members receive even more perks including all my full beginner courses and one new developer class each month.
You can find a complete video tutorial with step-by-step instructions on everything discussed here on my website at the link below.
Live long and prosper, my friends.
Topic List
Adding the Windows Media Player ActiveX control to Access forms Renaming the Windows Media Player control for easy reference Understanding compatibility issues with ActiveX controls Setting up a text box for video or audio file names Using CurrentProject.Path to reference the database folder Setting a default file name for media playback Adding a button to trigger video playback Writing VBA code to play selected video or audio files Linking the file path to the Windows Media Player control Explaining the URL property of the Windows Media Player control Testing and playing media files within Access forms Discussing resizing limitations of the Windows Media Player control
|