How to control windows media player with MATLAB?

조회 수: 4 (최근 30일)
kartheek
kartheek 2012년 7월 17일
답변: Gautam 2024년 11월 26일
I'm interested in doing projects with Matlab. I want to control Windows Media Player with matlab. Control in the sense, increasing and decreasing the volume, changing the track,etc... I don't know how to start or proceed. please help me out.

답변 (2개)

Daniel Shub
Daniel Shub 2012년 7월 17일
See this question.

Gautam
Gautam 2024년 11월 26일
MATLAB provides the capability to interact with COM objects, such as Windows Media Player, using ActiveX controls. You can use the actxcontrol function to embed Windows Media Player in the figure and UI controls to create buttons for play, stop, pause etc. The code below shows a workflow that can be implemented.
hFig = figure('Position', [100, 100, 600, 400], 'MenuBar', 'none', 'Name', 'Custom Media Player', 'NumberTitle', 'off');
hWMP = actxcontrol('WMPlayer.OCX.7', [0, 50, 600, 350], hFig);
uicontrol('Style', 'pushbutton', 'String', 'Play', 'Position', [10, 10, 50, 30], 'Callback', @(~,~) hWMP.controls.play());
uicontrol('Style', 'pushbutton', 'String', 'Pause', 'Position', [70, 10, 50, 30], 'Callback', @(~,~) hWMP.controls.pause());
uicontrol('Style', 'pushbutton', 'String', 'Stop', 'Position', [130, 10, 50, 30], 'Callback', @(~,~) hWMP.controls.stop());
However, please note that the function actxcontrol” relies on a third party technology, namely, Microsoft COM and Java Swing, and will be removed in a future version of MATLAB due to MathWorks transitioning its UI building infrastructure to web technologies. There is currently no simple replacement for this function. You can view UI alternatives for MATLAB apps in the document linked below
Also, the below File Exchange submission could provide you with useful alternatives:
For more information on the functions used, please refer to the documents below:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by