Embedding video in gui

7 次查看(过去 30 天)
Erkin Karatas
Erkin Karatas 2019-12-5
Hi all,
I want to embed 2 videos in matlab gui, When I press "First Video" button it should show the first video and when I press the "Second Video" button it should show the second video.
function varargout = untitled2(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled2_OpeningFcn, ...
'gui_OutputFcn', @untitled2_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled2 is made visible.
function untitled2_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for untitled2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = untitled2_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
Can anyone please help me with this? Thanks

回答(1 个)

Kavya Vuriti
Kavya Vuriti 2020-4-2
Hi,
This could be done easily using appdesigner. Type the following in command window:
>>appdesigner
This opens a canvas where we can start designing. Drag and drop two push buttons from common component library located on left side. In the right side of the window, the property inspector and callbacks of components are present. Add ButtonPushedFcn callback for both buttons and then shift to code view. You can write the corresponding code to play video in each of the callbacks.
You can use implay function to play video. Here is an example of using VideoReader object to play video.

Community Treasure Hunt

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

Start Hunting!

Translated by