source: trunk/SapphireVideoPlayer.m @ 123

Last change on this file since 123 was 123, checked in by pmerrill, 10 years ago
  • changed MyCompany? name to www.nanopi.net
  • added xml importing to the file import tool
File size: 1.9 KB
Line 
1//
2//  SapphireVideoPlayer.m
3//  Sapphire
4//
5//  Created by Graham Booker on 6/25/07.
6//  Copyright 2007 __www.nanopi.net__. All rights reserved.
7//
8
9#import "SapphireVideoPlayer.h"
10#import <QTKit/QTKit.h>
11
12@interface QTMovie (whoKnows)
13- (BOOL)hasChapters;
14@end
15
16@interface BRQTKitVideoPlayer (privateFunctions)
17- (BRVideo *)gimmieVideo;
18@end
19
20@interface BRVideo (privateFunctions)
21- (QTMovie *)gimmieMovie;
22@end
23
24@implementation BRQTKitVideoPlayer (privateFunctions)
25- (BRVideo *)gimmieVideo
26{
27        return _video;
28}
29@end
30
31@implementation BRVideo (privateFunctions)
32- (QTMovie *)gimmieMovie
33{
34        return _movie;
35}
36@end
37
38
39@implementation SapphireVideoPlayer
40
41- (id)init
42{
43        self = [super init];
44        if(!self)
45                return nil;
46       
47        revTime = ffTime = 5.0f;
48       
49        return self;
50}
51
52- (void)dealloc
53{
54        [resetTimer invalidate];
55        [meta release];
56        [super dealloc];
57}
58
59- (void)setMetaData:(SapphireFileMetaData *)newMeta
60{
61        meta = [newMeta retain];
62}
63
64- (BOOL)prerollMedia:(NSError * *)fp8
65{
66        BOOL ret = [super prerollMedia:fp8];
67       
68        if(!ret)
69                return ret;
70       
71        QTMovie *myMovie = [[self gimmieVideo] gimmieMovie];
72        if(![myMovie hasChapters])
73                enabled = TRUE;
74       
75        return ret;
76}
77
78- (void)setNewTimer
79{
80        [resetTimer invalidate];
81        resetTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(resetTimes) userInfo:nil repeats:NO];
82}
83
84- (void)resetTimes
85{
86        resetTimer = nil;
87        ffTime = revTime = 5.0f;
88}
89
90- (double)_nextChapterMark
91{
92        if(!enabled)
93                return [super _nextChapterMark];
94        double current = [self elapsedPlaybackTime];
95        double ret = current + ffTime;
96        ffTime *= 2.0f;
97        revTime = 5.0f;
98        [self setNewTimer];
99       
100        return ret;
101}
102
103- (double)_previousChapterMark
104{
105        if(!enabled)
106                return [super _previousChapterMark];
107        double current = [self elapsedPlaybackTime];
108        double ret = current - revTime;
109        revTime *= 2.0f;
110        ffTime = 5.0f;
111       
112        if(ret < 0.0f)
113                ret = 0.0f;
114        [self setNewTimer];
115
116        return ret;
117}
118
119@end
Note: See TracBrowser for help on using the repository browser.