Sheehan Alam
Sheehan Alam

Reputation: 60859

How can I launch QuickTime from my app?

I am trying to load a video from the web, but am having trouble getting it to appear in QuickTime. I can only hear the audio. I would like it to launch QuickTime.

- (void)loadView {
    NSURL *movieURL = [NSURL URLWithString:@"http://movies.apple.com/media/us/mac/getamac/2009/apple-mvp-biohazard_suit-us-20090419_480x272.mov"];


    if (movieURL != nil) {
        moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

        moviePlayer.initialPlaybackTime = -1.0;

        // Register to receive a notification when the movie has finished playing. 
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(moviePlayBackDidFinish:) 
                                                     name:MPMoviePlayerScalingModeDidChangeNotification 
                                                   object:moviePlayer];

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(endPlay:) 
                                                     name:MPMoviePlayerPlaybackDidFinishNotification 
                                                   object:moviePlayer];

        moviePlayer.scalingMode = MPMovieScalingModeAspectFit; 
        moviePlayer.movieControlMode = MPMovieControlModeDefault;
        moviePlayer.backgroundColor = [UIColor blackColor];

        [moviePlayer play];
    }
}

Upvotes: 1

Views: 496

Answers (3)

Philipp Li
Philipp Li

Reputation: 539

another solution to getting it to appear in QuickTime is:

NSString * urlStr = @"http://movies.apple.com/media/us/mac/getamac/2009/apple-mvp-biohazard_suit-us-20090419_480x272.mov";
NSString * htmlStr = [[@"<html><body><video preload=\"auto\" autoplay=\"true\"><source src=\"" stringByAppendingString:urlStr] stringByAppendingString:@"\"></video></body></html>"];
UIWebView * wv = [[UIWebView alloc] init];
wv.frame = self.view.frame;
[self.view addSubview:wv];
wv.hidden = true;
wv.mediaPlaybackRequiresUserAction = false;
[wv loadHTMLString:htmlStr baseURL:nil];

but you have to remove the webview from superview manually when quicktime player is closed.

Upvotes: 0

Sheehan Alam
Sheehan Alam

Reputation: 60859

i used the view controller instead:

moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:mySTVideo.video_url]];

[self presentModalViewController:moviePlayerViewController animated:YES];

[moviePlayerViewController release];

Upvotes: 1

DenverCoder9
DenverCoder9

Reputation: 3705

Have you tried it on the device? I've heard of the simulator sometimes having this problem when the device is OK.

Upvotes: 0

Related Questions