Reverse Playback with AV Foundation

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
giodev
Posts: 10
Joined: Fri May 01, 2015 8:35 am

Reverse Playback with AV Foundation

Post by giodev » Thu Sep 10, 2015 10:38 am

Hi guys,

Part of the application that I'm developing requires a video to be able to play backwards, the main target platform is Windows were it works as expected, however there is a call for the program on Mac as well, where it currently doesn't. I'm aware that QuickTime has been replaced with AV Foundation for the implementation on Mac, but obviously I need to figure something out here!

Basically my question boils down to two parts:
1) Is there a way to play a video backwards on Mac that I don't know about? (I've thought about repeatedly stepping back 1 frame X times a second, where X is the frame rate of the video, but I imagine that will kill performance)
2) I believe that in direct Mac development in C++, reverse playback with AV Foundation is possible, so are there plans to include that in a future version of LiveCode?

I'm kind of assuming that the second question is only answerable by devs, unless there is a roadmap for development that I haven't seen.

Anyway, any response would be good, thanks for reading!

Klaus
Posts: 13871
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Reverse Playback with AV Foundation

Post by Klaus » Thu Sep 10, 2015 12:23 pm

Hi giodev,

yep, that's possible, check "playrate" in the dictionary!
Setting this to a negative number will play the video backwards.


Best

Klaus

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 821
Joined: Fri Feb 06, 2015 4:03 pm

Re: Reverse Playback with AV Foundation

Post by LiveCode_Panos » Thu Sep 10, 2015 12:52 pm

Hi giodev,

As Klaus pointed out, you can use the 'playrate' property of the player object. In short:

play player 1 --> sets the playrate to 1 and plays the video forward
stop player 1 --> sets the playrate to 0 and stops playback
set the playrate of player 1 to -1 --> plays the video backwards

Best,
Panos
--

giodev
Posts: 10
Joined: Fri May 01, 2015 8:35 am

Re: Reverse Playback with AV Foundation

Post by giodev » Fri Sep 11, 2015 9:27 am

Hi guys, thanks for the quick responses!

I was already setting the playRate property to -1 and playing. The problem was (which as far as I can see in the Dictionary is undocumented) that I was following setting the playRate with starting the player, i.e.:

set the playRate of player "Player" to -1
start player "Player"

The above will make the player play forwards, which to me is not intuitive, but I can sort of understand why it does so.
I think updating the Dictionary for the start keyword to point out that it resets the playRate would be a good idea, and probably another amendment to say that setting the playRate will start the player as well.

Anyway, thanks, removed the line and we're back in business.

Post Reply

Return to “Mac OS”