summaryrefslogtreecommitdiffstats
path: root/macosx/QTKit+HBQTMovieExtensions.m
blob: 903659ec9509b42b978b344224f107bb54d7822c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* QTKit+HBQTMovieExtensions.m

 This file is part of the HandBrake source code.
 Homepage: <http://handbrake.fr/>.
 It may be used under the terms of the GNU General Public License. */

#import "QTKit+HBQTMovieExtensions.h"

@implementation QTMovieView (HBQTMovieViewExtensions)

- (void)mouseMoved:(NSEvent *)theEvent
{
    [super mouseMoved:theEvent];
}

@end

@implementation QTMovie (HBQTMovieExtensions)

- (BOOL)isPlaying
{
    if (self.rate > 0)
    {
        return YES;
    }
    else
    {
        return NO;
    }
}

- (NSString *)timecode
{
    QTTime time = [self currentTime];
    double timeInSeconds = (double)time.timeValue / time.timeScale;
    UInt16 seconds = (UInt16)fmod(timeInSeconds, 60.0);
    UInt16 minutes = (UInt16)fmod(timeInSeconds / 60.0, 60.0);
    UInt16 hours = (UInt16)(timeInSeconds / (60.0 * 60.0));
    UInt16 milliseconds = (UInt16)(timeInSeconds - (int) timeInSeconds) * 1000;
    return [NSString stringWithFormat:@"%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds];
}

- (void)setCurrentTimeDouble:(double)value
{
    long timeScale = [[self attributeForKey:QTMovieTimeScaleAttribute] longValue];
    [self setCurrentTime:QTMakeTime((long long)value * timeScale, timeScale)];
}

@end