Please format your code. Highlight the code portion of the text and click on the "{}Code" button.
callback stop
4 次查看(过去 30 天)
显示 更早的评论
Hi
I wamt to set up button controling "stop" video, but when I push one "stop" button,then the button callback one video stop,other video also play video continuely.
this is my code
function vidplayer()
obj = mmreader('can.avi');
obj1 = mmreader('watch.avi');
obj2 = mmreader('phone.avi');
obj3 = mmreader('can.avi');
v = read(obj);
v1 = read(obj1);
v2 = read(obj2);
v3 = read(obj3);
figure('Name','scene ',...
'NumberTitle','off',...
'Visible','on',...
'Position',[150 100 1000 500],...
'Color',[1,1,0.95],'HandleVisibility','on',...
'Menubar','none',...
'IntegerHandle','off',...
'Resize','on');
hstat = uicontrol('style','checkbox','value',0,'position',...
[160 10 25 25]);
hplay = uicontrol('style','pushbutton','string','PLAY',...
'position',[10 130 50 25],'backgroundColor',[1,1,0.2],'callback',{@play_callback,v});
hplay = uicontrol('style','pushbutton','string','PLAY',...
'position',[10 90 50 25],'backgroundColor',[1,1,0.2],'callback',{@play_callback1,v1});
hplay = uicontrol('style','pushbutton','string','PLAY',...
'position',[10 50 50 25],'backgroundColor',[1,1,0.2],'callback',{@play_callback2,v2});
hplay = uicontrol('style','pushbutton','string','PLAY',...
'position',[10 10 50 25],'backgroundColor',[1,1,0.2],'callback',{@play_callback3,v3});
hstop = uicontrol('style','pushbutton','string','STOP',...
'position',[60 130 50 25],'backgroundColor',[1,0.5,0.5],'callback',{@stop_callback,v});
hstop = uicontrol('style','pushbutton','string','STOP',...
'position',[60 90 50 25],'backgroundColor',[1,0.5,0.5],'callback',{@stop_callback1,v1});
hstop = uicontrol('style','pushbutton','string','STOP',...
'position',[60 50 50 25],'backgroundColor',[1,0.5,0.5],'callback',{@stop_callback2,v2});
hstop = uicontrol('style','pushbutton','string','STOP',...
'position',[60 10 50 25],'backgroundColor',[1,0.5,0.5],'callback',{@stop_callback3,v3});
hexit = uicontrol('style','pushbutton','string','EXIT',...
'position',[110 10 50 25],'backgroundColor',[1,0,0.1],'callback',@exit_callback);
function play_callback(hObject,eventdata,vid)
set(hstat,'value',1);
for frame = 1 : size(vid,4)
if get(hstat,'value') == 1,
subplot(2,2,1); imshow(vid(:,:,:,frame));
drawnow;
else, break; end
end
end
function play_callback1(hObject,eventdata,vid)
set(hstat,'value',1);
for frame = 1 : size(vid,4)
if get(hstat,'value') == 1,
subplot(2,2,2); imshow(vid(:,:,:,frame));
drawnow;
else, break; end
end
end
function play_callback2(hObject,eventdata,vid)
set(hstat,'value',1);
for frame = 1 : size(vid,4)
if get(hstat,'value') == 1,
subplot(2,2,3); imshow(vid(:,:,:,frame));
drawnow;
else, break; end
end
end
function play_callback3(hObject,eventdata,vid)
set(hstat,'value',1);
for frame = 1 : size(vid,4)
if get(hstat,'value') == 1,
subplot(2,2,4); imshow(vid(:,:,:,frame));
drawnow;
else, break; end
end
end
function stop_callback(hObject,eventdata,vid)
set(hstat,'value',0);
end
function stop_callback1(hObject,eventdata,vid)
set(hstat,'value',0);
end
function stop_callback2(hObject,eventdata,vid)
set(hstat,'value',0);
end
function stop_callback3(hObject,eventdata,vid)
set(hstat,'value',0);
end
function exit_callback(hObject,eventdata)
stop_callback;
close gcf;
end
end
please give me something advice. Thank!
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!