MATLAB Answers

Embedding video in gui

6 views (last 30 days)
Erkin Karatas
Erkin Karatas on 5 Dec 2019
Answered: Kavya Vuriti on 2 Apr 2020
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

  0 Comments

Sign in to comment.

Answers (1)

Kavya Vuriti
Kavya Vuriti on 2 Apr 2020
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.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!