How to use popup menu
6 次查看(过去 30 天)
显示 更早的评论
I want to sue popup menu that control play the videos.
This is my code.
function f2()
clear all;
obj1 = mmreader('phone.avi');
obj2 = mmreader('can.avi');
%obj3 = mmreader('book.avi');
%obj4 = mmreader('phone.avi');
vid1 = read(obj1);
vid2 = read(obj2);
%vid3 = read(obj3);
%vid4 = read(obj4);
frame1 = 1;
frame2 = 50;
% frame3 = 30;
% frame4 = 1;
f4 = 1;
hst1=0;
hst2=0;
% hst3=0;
% hst4=0;
h = figure('Name','Video ', 'NumberTitle','off','Color',[1,1,1],'Toolbar','none','Visible','on', 'Position',[30 40 1000 700],...
'Resize','on','menu','none');
hstat1 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
[50 530 25 25],'units','normalized');
hstat2 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
[50 450 25 25],'units','normalized');
% hstat3 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
% [50 480 25 25]);
% hstat4 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
% [50 410 25 25]);
hplay1 = uicontrol('unit','pixel','style','pushbutton','string','藥罐_PLAY',...
'position',[50 530 70 40],'backgroundColor',[0.3,0.7,1],'units','normalized','callback',{@play1_callback});
hplay2 = uicontrol('unit','pixel','style','pushbutton','string','手錶_PLAY',...
'position',[50 450 70 40],'backgroundColor',[0.3,0.7,1],'units','normalized','callback',{@play2_callback});
%hplay3 = uicontrol('unit','pixel','style','pushbutton','string','書本_PLAY',...
%'position',[50 480 70 40],'backgroundColor',[0.3,0.7,1],'callback',{@play3_callback});
%hplay4 = uicontrol('unit','pixel','style','pushbutton','string','手機_PLAY',...
%'position',[50 410 70 40],'backgroundColor',[0.3,0.7,1],'callback',{@play4_callback});
hstop1 = uicontrol('unit','pixel','style','pushbutton','string','藥罐_STOP',...
'position',[50 370 70 40],'backgroundColor',[0.2,1,0],'units','normalized','callback',@stop1_callback);
hstop2 = uicontrol('unit','pixel','style','pushbutton','string','手錶_STOP',...
'position',[50 290 70 40],'backgroundColor',[0.2,1,0],'units','normalized','callback',@stop2_callback);
% hstop3 = uicontrol('unit','pixel','style','pushbutton','string','書本_STOP',...
% 'position',[50 170 70 40],'backgroundColor',[0.2,1,0],'callback',@stop3_callback);
% hstop4 = uicontrol('unit','pixel','style','pushbutton','string','手機_STOP',...
% 'position',[50 90 70 40],'backgroundColor',[0.2,1,0],'callback',@stop4_callback);
hexit = uicontrol('unit','pixel','style','pushbutton','string','EXIT',...
'position',[50 210 70 40],'backgroundColor',[1,0,0],'units','normalized','callback',@exit_callback);
while (1)
if hst1==1
%subplot('Position',[left bottom width height])
%subplot(2,1,1,'Position',[0 0 320 240]); imshow(vid1(:,:,:,frame1));
subplot(2,1,1); imshow(vid1(:,:,:,frame1),'InitialMagnification','fit');
%imshow(checkerboard)
%truesize(a,[640 480]);
if frame1 < size(vid1,4)
frame1 = frame1+1;
else
frame1 = 1;
end
end
if hst2==1
subplot(2,1,2); imshow(vid2(:,:,:,frame2));
if frame2 < size(vid2,4)
frame2 = frame2+1;
else
frame2 = 1;
end
end
% if hst3==1
% subplot(2,2,3); imshow(vid3(:,:,:,frame3));
% if frame3 < size(vid3,4)
% frame3 = frame3+1;
% else
% frame3 = 1;
% end
% end
%
% if hst4==1
% subplot(2,2,4); imshow(vid4(:,:,:,frame4));
% if frame4 < size(vid4,4)
% frame4 = frame4+1;
% else
% frame4 = 1;
% end
% else
% subplot(2,2,4); imshow(vid2(:,:,:,1));
%end
drawnow;
if f4 ==10000
break;
% else f4 = f4+1;
end
end
function play1_callback(hObject0,eventdata0)
set(hstat1,'value',1);
hst1=1;
set(hplay1 ,'backgroundColor',[1,1,0],'string','藥罐_播放中');
%set(gcf,'units','normalized','position',[0 0 1 1]);
end
function play2_callback(hObject1,eventdata1)
set(hstat2,'value',1);
hst2=1;
set(hplay2 ,'backgroundColor',[1,1,0],'string','手錶_播放中');
end
% function play3_callback(hObject2,eventdata2)
% set(hstat3,'value',1);
% hst3=1;
% set(hplay3 ,'backgroundColor',[1,1,0],'string','書本_播放中');
% end
% function play4_callback(hObject3,eventdata)
% set(hstat4,'value',1);
% hst4=1;
% set(hplay4 ,'backgroundColor',[1,1,0],'string','手機_播放中');
% end
function stop1_callback(hObject,eventdata)
set(hstat1,'value',0);
hst1=0;
set(hplay1 ,'backgroundColor',[0.3,0.7,1],'string','藥罐_PLAY');
end
function stop2_callback(hObject,eventdata)
set(hstat2,'value',0);
hst2=0;
set(hplay2 ,'backgroundColor',[0.3,0.7,1],'string','手錶_PLAY');
end
% function stop3_callback(hObject,eventdata)
% set(hstat3,'value',0);
% hst3=0;
% set(hplay3 ,'backgroundColor',[0.3,0.7,1],'string','書本_PLAY');
% end
%
% function stop4_callback(hObject,eventdata)
% set(hstat4,'value',0);
% hst4=0;
% set(hplay4 ,'backgroundColor',[0.3,0.7,1],'string','手機_PLAY');
% end
function exit_callback(hObject,eventdata)
f4=1000;
stop1_callback;
close gcf;
end
end
I want to replace the current play button with a popup menu.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!