VC15 只播放视频,不显示文件名
时间: 2023-08-26 12:03:42 浏览: 76
你可以使用VC15(Visual C++ 2015)提供的Windows Media Player控件来实现只播放视频,不显示文件名的功能。具体步骤如下:
1. 在Visual Studio中创建一个新的Win32应用程序项目。
2. 在资源编辑器中添加一个Windows Media Player控件。
3. 在窗口过程函数中,使用以下代码设置Windows Media Player控件的URL属性为视频文件的路径:
```C++
HWND hWndPlayer = GetDlgItem(hwnd, IDC_MEDIAPLAYER);
SendMessage(hWndPlayer, WM_APP, 0, 0);
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CREATE:
{
HWND hWndPlayer = CreateWindow(L"MediaPlayer", NULL, WS_CHILD | WS_VISIBLE, 0, 0, 640, 480, hwnd, (HMENU)IDC_MEDIAPLAYER, GetModuleHandle(NULL), NULL);
ShowWindow(hWndPlayer, SW_SHOW);
}
break;
case WM_APP:
{
HWND hWndPlayer = GetDlgItem(hwnd, IDC_MEDIAPLAYER);
IWMPPlayer* pPlayer = NULL;
HRESULT hr = CoCreateInstance(CLSID_WindowsMediaPlayer, NULL, CLSCTX_INPROC_SERVER, IID_IWMPPlayer, (void**)&pPlayer);
if (SUCCEEDED(hr))
{
BSTR bstrURL = SysAllocString(L"C:\\Videos\\example.mp4");
pPlayer->put_URL(bstrURL);
SysFreeString(bstrURL);
pPlayer->Release();
}
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
}
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
```
4. 在Windows Media Player控件的属性窗口中,将uiMode属性设置为"none",这样就不会显示文件名。
5. 在Windows Media Player控件的属性窗口中,将settingsMode属性设置为"none",这样就不会显示Windows Media Player的控制条和其他界面元素。
这样就可以实现只播放视频,不显示文件名的功能了。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)