Automatically Play Video Using Implay Function

I am trying to use the implay(filename) function to play a video file inside of MATLAB. The function works well and plays the video correctly but it does not automatically launch and play the video when the code is submitted. Instead I have to manually press the play button. I'm doing a Psychology research project in which the timing of the video playing is crucial to the data collection.
Is there additional code that can be submitted to have implay automatically launch the video play and play the video?
Additionally I have tried using the: movie (hf, mov, 1, readerobj.FrameRate); code to play the video with VideoReader but it plays the video at a slower framerate than the original video. This is also no good for my study. If anyone knows how to fix that I think I could go that route instead.
Thanks so much!

1 件のコメント

Ranjithkumar Dinakaran
Ranjithkumar Dinakaran 2016 年 8 月 18 日
h = mplay('rhinos.avi');
play(h.DataSource.Controls);
try this, it works for me

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

回答 (2 件)

Sean de Wolski
Sean de Wolski 2012 年 3 月 29 日

0 投票

I haven't been able to find a way to do it. It's easy to program it to stop or pause but not to play or resume... I'm sure with lots of time digging through the objects, the secret would be found.
I would recommend building your own implay using a timer with an appropriate timerfcn in a GUI that calls imshow.

2 件のコメント

Tilacore
Tilacore 2012 年 3 月 29 日
So you're saying to set a timer relative to the rest of what I am doing and once the timer "goes off" it will automatically play the video?
Sean de Wolski
Sean de Wolski 2012 年 3 月 30 日
basically yes, it'll show the images at a fixed rate of your choosing.

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

Walter Roberson
Walter Roberson 2012 年 3 月 29 日

0 投票

I wonder if the Java Robot Class could be used?
Or if one could get the handle to the Callback property and call the function directly.

5 件のコメント

Tilacore
Tilacore 2012 年 3 月 29 日
Unfortunately I am a newbie to this MATLAB stuff so I don't really know what you are referring too with Java Robot Class? I'm working with a professor who is rather fluent in MATLAB use and coding. He may have a better idea than I what you mean. Could you explain it a little differently to me?
What I think you mean is use another party's application to call MATLAB to play the video? Would that use the implay function as well? The problem I can see happening with that is that we are using MATLAB as an external trigger to start data collection from our movement and breathing tracking devices. Adding another application on top of that may not work.
Thanks for answering!
Walter Roberson
Walter Roberson 2012 年 3 月 29 日
No extra application needed. See
undocumentedmatlab.com
for information on Java Robot Class.
Walter Roberson
Walter Roberson 2012 年 3 月 29 日
編集済み: Walter Roberson 2020 年 8 月 17 日
Yeh, I was able to trace it deep enough to find the callback to call to trigger playback.
implay('rhinos.avi')
moviefig = findobj(0,'Type','figure', 'Tag','spcui_scope_framework');
playcb = get(findobj(moviefig,'Type','uimenu','Tag','Play'), 'Callback')
playcb(); %triggers the playing
Sean de Wolski
Sean de Wolski 2012 年 3 月 30 日
That's not working for me on 11b. It certainly appears to be barking up the right tree though. I tried to trace the callback through the various methods/properties of the various objects. Using findjobj, yesterday I found the callback to be playPause() or similar. Not able to find it right now though and I wasn't able to use it yesterday.
Walter Roberson
Walter Roberson 2012 年 3 月 30 日
I tried both ways and found chasing down through the menus to be the easiest way. You end up looking for the uimenu whose label is Play, pulling out its callback and invoking that callback. Finding the right figure number is more magical, and I would think it probable that the Tag has evolved away from the tag that I found.

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

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

タグ

質問済み:

2012 年 3 月 29 日

編集済み:

2020 年 8 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by