【问题标题】:Video Output not visible视频输出不可见
【发布时间】:2012-09-28 18:59:24
【问题描述】:

我正在制作一个可以在 ios 模拟器上显示预加载文件的应用程序。虽然模拟器上显示屏幕,但我看不到视频也听不到声音。

这是我的代码。

#import "BIDViewController.h"

@implementation BIDViewController
@synthesize moviePlayer;


-(IBAction)playMovie:(id)sender
{
NSString *url = [[NSBundle mainBundle]
                pathForResource:@"SwimGood" ofType:@"m4v"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc]
                                initWithContentURL:[NSURL fileURLWithPath:url]];
//Play partial screen.

player.view.frame = CGRectMake(64, 100, 200, 150);

[self.view addSubview: player.view];
[self.moviePlayer prepareToPlay];

[player play];
}

【问题讨论】:

  • 是的,我非常感谢@sarafarazBabi
  • 干杯!我已经做到了..再次感谢您的帮助

标签: ios xcode ios-simulator media-player ios6


【解决方案1】:

我是这样使用的

NSString *videoFilepath = [[NSBundle mainBundle] pathForResource:[tempDic objectForKey:@"VideoName"] ofType:@"mov"];

NSURL *url = [NSURL fileURLWithPath:videoFilepath];

MPMoviePlayerController *playerViewController =[[MPMoviePlayerController alloc] init]; playerViewController.view.frame = CGRectMake(6, 5, 308, 202);

[playerViewController setContentURL:url];
playerViewController.controlStyle = MPMovieControlStyleNone;
[playerViewController prepareToPlay];
  [self.view addSubview:[playerViewController view]];

它工作正常..所以它可能是文件类型的问题。所以尝试使用 .mov

别忘了导入 MediaPlayer/MediaPlayer.h 并添加 MediaPlayer 框架,它在您的主包中不存在。

祝你好运……

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多