How can I interrupt a movie based on user input to a GUI

1 回表示 (過去 30 日間)
Sean
Sean 2011 年 7 月 14 日
I have a GUI that displays video to a user. I want the video to stop playing when the user presses a particular button. Unfortunately, the movie (I am using the movie() command) continues to play until it is done on its own.
How can I interrupt the playback of movie() based on a buttonpress event (i.e. from a user event callback).
BTW, I don't believe Ctrl-C will work, because I don't want the GUI to stop running. I want to terminate the movie running in a particular axes on the GUI, and start another movie in the same axes.
Thanks in advance, Sean
  1 件のコメント
Sean
Sean 2011 年 7 月 15 日
I have also tried to kill the axes that the video is running in (using the axes handle), but I get an error (presumably because movie() is still actively using the axes?)

サインインしてコメントする。

採用された回答

Sean de Wolski
Sean de Wolski 2011 年 7 月 15 日
A totally different approach:
Instead of playing the movie with movie; write a function that traverses the frames and displays them using imshow. Start the movie, set the frame rate etc. using a timer and stop the timer to stop the movie. Useful documentation:
doc timer
This obviously will require more work; but can be tuned to give you exactly what you want.
  1 件のコメント
Sean
Sean 2011 年 7 月 21 日
Thank you. I had never used timers before (still relatively new to matlab), but this turned out to do exactly what I wanted.

サインインしてコメントする。

その他の回答 (2 件)

B_Richardson
B_Richardson 2011 年 7 月 14 日
  1 件のコメント
Sean
Sean 2011 年 7 月 15 日
Thank you. I appreciate your looking this up, but... This solution appears to be overly complicated for what I am working on.
I am playing short clips and letting an operator grade the video quality of each, not trying to run a general purpose media player. (This example would increase my code size by more than an order of magnitude).
Thanks again though. :)

サインインしてコメントする。


Sean de Wolski
Sean de Wolski 2011 年 7 月 15 日
You could kill the axes inside a try/catch block so that the error is not reported and so that nothing bad happens.
  1 件のコメント
Sean
Sean 2011 年 7 月 15 日
Thanks for the tip... I hadn't run into try/catch before.
Using this I was able to see that the "delete(h.video)" was not generating the error (technically anyway). The delete executes fine, but the axes just stays there and continues running (presumably because movie() is still running).
Unfortunately, from that point on movie() still runs in the axes and any further references to h.video generate errors.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by