在iOS 5中播放视频 [英] playing video in iOS 5

查看:120
本文介绍了在iOS 5中播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照本教程链接,但我遇到了问题。有人可以看看,让我知道需要改变什么。
我试图查找其他示例,但似乎都没有。请告诉我需要更改的内容。

I am trying to follow this tutorial link, but i have issues. Can somebody please have a look and let me know what needs to be changed. I tried to looking up other examples but none seems to work. Please let me know what needs to be changed.

以下是错误

架构i386的未定义符号:
_ OBJC_CLASS _ $ _ MPMoviePlayerController,引用自:
objc-class-ref在VideoScreenViewController.o
_MPMoviePlayerPlaybackDidFinishNotification中,引自:
- VideoScreenViewController中的[VideoScreenViewController playVideo:] .o
- VideoScreenViewController.o中的[VideoScreenViewController moviePlayBackDidFinish:]
ld:找不到架构i386的符号
clang:错误:链接器命令失败,退出代码为1(使用-v看到调用)

Undefined symbols for architecture i386: "_OBJC_CLASS_$_MPMoviePlayerController", referenced from: objc-class-ref in VideoScreenViewController.o "_MPMoviePlayerPlaybackDidFinishNotification", referenced from: -[VideoScreenViewController playVideo:] in VideoScreenViewController.o -[VideoScreenViewController moviePlayBackDidFinish:] in VideoScreenViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

这是代码

//  VideoScreenViewController.h

#import <UIKit/UIKit.h>
#import "MediaPlayer/MediaPlayer.h"
@interface VideoScreenViewController : UIViewController

@property (strong, nonatomic) MPMoviePlayerController *moviePlayer;

- (IBAction)playVideo:(id)sender;

@end

    }


#import "VideoScreenViewController.h"
#import "MediaPlayer/MediaPlayer.h"
@interface VideoScreenViewController ()

@end

@implementation VideoScreenViewController

@synthesize moviePlayer;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    self.view.backgroundColor = [UIColor clearColor];
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)playVideo:(id)sender {

        NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] 
                                             pathForResource:@"Movie" ofType:@"MOV"]];
        moviePlayer =  [[MPMoviePlayerController alloc]
                        initWithContentURL:url];

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

        moviePlayer.controlStyle = MPMovieControlStyleDefault;
        moviePlayer.shouldAutoplay = YES;
        [self.view addSubview:moviePlayer.view];
        [moviePlayer setFullscreen:YES animated:YES];


}


- (void) moviePlayBackDidFinish:(NSNotification*)notification {

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] 
                                         pathForResource:@"Movie" ofType:@"MOV"]];
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
    [[NSNotificationCenter defaultCenter] 
     removeObserver:self
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:player];

    if ([player
         respondsToSelector:@selector(setFullscreen:animated:)])
    {
        [player.view removeFromSuperview];
    }
}

@end


推荐答案

将MediaPlayer.framework添加到您的项目......然后尝试..

Add MediaPlayer.framework to your project..and then try..

这篇关于在iOS 5中播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆