Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop Mode implemented #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions v002 Media Tools/v002_Movie_PlayerPlugIn.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ + (NSDictionary *)attributesForPropertyPortWithKey:(NSString *)key
return @{QCPortAttributeNameKey:@"Rate", QCPortAttributeDefaultValueKey:[NSNumber numberWithFloat:1.0]};

if([key isEqualToString:@"inputLoopMode"])
return @{QCPortAttributeNameKey : @"Playhead",
return @{QCPortAttributeNameKey : @"Loop Mode",
QCPortAttributeMenuItemsKey : @[@"Loop", @"Palindrome", @"No Loop"],
QCPortAttributeMinimumValueKey : [NSNumber numberWithUnsignedInteger:0],
QCPortAttributeDefaultValueKey : [NSNumber numberWithUnsignedInteger:0],
Expand Down Expand Up @@ -260,13 +260,35 @@ - (BOOL)execute:(id <QCPlugInContext>)context atTime:(NSTimeInterval)time withAr
// output port values
BOOL end = self.movieDidEnd;

if(end)
if(end)
{
self.outputMovieDidEnd = YES;
self.movieDidEnd = NO;

// QCPortAttributeMenuItemsKey : @[@"Loop", @"Palindrome", @"No Loop"],
if (self.inputLoopMode == 0)
{
[[player currentItem] seekToTime:kCMTimeZero];
[player setRate:self.inputRate];
}
else if (self.inputLoopMode == 1)
{
// Rate is already zero by the time we get here.
// Don't rely on reversePlaybackEndTime comparison
if (CMTimeCompare([player currentTime], kCMTimeZero) > 0)
{
[player setRate: -1.0 * fabs(self.inputRate)];
}
else
{
[player setRate: fabs(self.inputRate)];
}
}
}
else
{
self.outputMovieDidEnd = YES;
self.movieDidEnd = NO;
self.outputMovieDidEnd = NO;
}
else
self.outputMovieDidEnd = NO;

return YES;
}
Expand Down