【问题标题】:How to play a video file from the URL of type .3gp如何从 .3gp 类型的 URL 播放视频文件
【发布时间】:2013-11-08 15:39:17
【问题描述】:

提前致谢。我想实现代码以从 URL 以编程方式在 iphone 中播放视频。我已经写了这样的代码。

 NSURL *url = [NSURL    URLWithString:@"http://91.220.127.40/Celebrity_subCategoryItems/rc4.3gp"];//@"http://www.businessfactors.de/bfcms/images/stories/videos/defaultscreenvideos.mp4"];
MPMoviePlayerController *player =[[MPMoviePlayerController alloc] initWithContentURL:     url];
[[player view] setFrame: [self.view bounds]];  // frame must match parent view
[self.view addSubview: [player view]];
[player play];

但它没有播放 .3gp 类型的文件。如果有人知道,请帮助我。

【问题讨论】:

  • Apple 文档的哪一部分告诉您使用 3GP 文件?
  • 我不知道直到。 iphone不能用3gp文件吗?
  • 嗯,3GP 是一种稍微受限制的 MP4 格式 - 因此它可能会起作用,但通常它不起作用。您选择的格式是用于渐进式下载的 MP4 (M4V) 或用于适当的自适应流媒体的 M3U8(HTTP 视频流)。您真的应该查阅编写良好的 Apple 文档。

标签: iphone


【解决方案1】:

我已经用 iphone sdk 成功玩过 .3gp,我的代码是:

NSString *soundLocalPath  = [[NSBundle mainBundle] pathForResource:@"Demo_video" ofType:@"3gp"];

NSURL *tempUrl   = [NSURL fileURLWithPath:soundLocalPath];

self.soundUrlPath = tempUrl;

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: self.soundUrlPath];

self.mpMoviePlayer = player;

[player release];

[self.mpMoviePlayer prepareToPlay];
[self.mpMoviePlayer.view setFrame: self.view.bounds];  // player's frame must match parent's

[self.view addSubview: self.mpMoviePlayer.view];

[self.mpMoviePlayer play];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(movieFinishedCallback:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:player];


-(void) movieFinishedCallback:(NSNotification*) aNotification
{
    MPMoviePlayerController *player = [aNotification object];

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:player];

    [player autorelease];
}

【讨论】:

  • MPMoviePlayerController *mpMoviePlayer; @property(保留,非原子) MPMoviePlayerController *mpMoviePlayer;在 .h 文件中定义。
【解决方案2】:

我们还可以播放扩展名为 .3gp 的文件,但要播放我们需要一些压缩标准,以便将文件转换为所有移动设备支持的格式(3GPP - 移动平衡质量 [H.263 接近 128 kbps,10 fps , 128*96; AMR)).所以它现在正在播放。

【讨论】:

  • 嗨 @Vennela 你能告诉我如何以标准格式压缩这个视频吗?提前谢谢
猜你喜欢
  • 2012-11-04
  • 2011-11-22
  • 2012-01-30
  • 2013-11-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-18
  • 2014-11-02
  • 2011-08-08
相关资源
最近更新 更多