LYY41742 2023-03-22 19:54 采纳率: 50%
浏览 90

VS+EasyX+API如何实现在原窗体中播放视频

现在用以下代码可以实现播放视频,但是会默认打开一个新的框体
如何直接在原框体播放这个视频呢?
希望能直接提供一份可正常运行且能实现期望效果的代码

#include<graphics.h>
#include<cstring>
#include<stdio.h>
#include<easyx.h>
#include <conio.h>
#include<windef.h>//EasyX 图像库头文件,用于绘图、鼠标操作、键盘操作等功能
#include<mmsystem.h>//包含多媒体设备接口头文件
#include<textstor.h>
#include<winuser.h>
#pragma comment(lib,"winmm.lib")//加载静态库
#pragma comment(lib,"MSIMG32.LIB")
using namespace std;
const int WIDTH = 960, HIGHT = 400;
int main()
{
    initgraph(WIDTH, HIGHT, EX_SHOWCONSOLE); 
    mciSendString("open \"video.avi\" type mpegvideo alias movie", NULL, 0, NULL);
    mciSendString("play movie", NULL, 0, NULL);
    
    char ch = getchar();
    closegraph();
}


  • 写回答

1条回答 默认 最新

  • 赵4老师 2023-03-23 09:44
    关注
    window
    The window command controls the display window. You can use this command to change the display characteristics of the window or provide a destination window for the driver to use in place of the default display window. Digital-video, and video-overlay devices recognize this command. 
    
    wsprintf(lpstrCommand, "window %s %s %s", lpszDeviceID, lpszWindowFlags, 
        lpszFlags); 
     
    Parameters
    lpszDeviceID 
    Identifier of an MCI device. This identifier or alias is assigned when the device is opened. 
    lpszWindowFlags 
    Flag for controlling the display window. The following table lists device types that recognize the window command and the flags used by each type: digitalvideo handle hwnd
    state hide
    state minimize
    state restore
    state show
    show maximized show minimized
    show min noactive
    show na
    show noactivate
    show normal
    text caption 
    overlay fixed
    handle default
    handle hwnd
    state hide
    state iconic
    state maximized
    state minimize
    state minimized
    state no action
    state no activate
    state normal state restore
    state show
    show maximized
    show minimized
    show min noactive
    show na
    show noactivate
    show normal
    stretch
    text caption 
    
    
    The following table lists the flags that can be specified in the lpszWindowFlags parameter and their meanings: fixed Disables stretching of the image. 
    handle default Specifies that the device should set the display window back to the default window created during the open operation. For video-overlay devices, specifies that the device should create and manage its own destination window. 
    handle hwnd Specifies the handle of the destination window to use instead of the default window. The hwnd parameter contains the ASCII numeric equivalent of the window handle returned by theCreateWindow function. Two device instances can use the same window handle provided that each instance updates the video and image pixels in the window as if the other instance did not exist. When video output is disabled with setvideo "off", an update command will make the destination rectangle a solid color. 
    show maximized Maximizes the destination window. 
    show min noactive Displays the destination window as an icon. 
    show minimized Minimizes the destination window. 
    show na Displays the destination window in its current state; the window that is currently active remains active. 
    show noactivate Displays the destination window in its most recent size and position; the window that is currently active remains active. 
    show normal Activates and displays the destination window in its original size and position. (This is the same as the "state restore" flag.)  
    state hide Hides the destination window. 
    state iconic Displays the destination window as an icon. 
    state maximized Maximizes the destination window. 
    state minimize Minimizes the destination window and activates the top-level window in the window-manager's list.  
    state minimized Minimizes the destination window. 
    state no action Displays the destination window in its current state. The window that is currently active remains active. 
    state no activate Displays the destination window in its most recent size and state. The currently active window remains active. 
    state normal Activates and displays the destination window in its original size and position. 
    state restore Activates and displays the destination window in its original size and position. 
    state show Shows the destination window. 
    stretch Enables stretching of the image. 
    text caption Specifies the caption for the destination window. If this text contains embedded blanks, the entire caption must be enclosed in quotation marks. The default caption for the default window is blank. 
    
    
    
    lpszFlags 
    Can be "wait", "notify", or both. For digital-video devices, "test" can also be specified. For more information about these flags, see The Wait, Notify, and Test Flags. 
    Return Values
    Returns zero if successful or an error otherwise.
    
    Remarks
    Video-overlay devices typically create and display a window when opened. If your application provides a window to the driver, your application is responsible for managing the messages sent to the window.
    
    Since you can use the status command to retrieve the handle to the driver display window, you can also use the standard window manager functions (such asShowWindow) to manipulate the window. 
    
    The following command displays and sets the caption for the "movie" playback window:
    
    window movie text "Welcome to the Movies" state show
     
    QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Unsupported.
    
    See Also
    MCI Overview, MCI Command Strings,CreateWindow, open, play, setvideo,ShowWindow, status, update 
    
    
     
    
    
    
    评论

报告相同问题?

问题事件

  • 创建了问题 3月22日

悬赏问题

  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像