最簡單的基於FFmpeg的移動端例子附件:IOS內建播放器,ffmpegios

來源:互聯網
上載者:User

最簡單的基於FFmpeg的移動端例子附件:IOS內建播放器,ffmpegios

=====================================================

最簡單的基於FFmpeg的移動端例子系列文章列表:

最簡單的基於FFmpeg的移動端例子:Android HelloWorld

最簡單的基於FFmpeg的移動端例子:Android 視頻解碼器

最簡單的基於FFmpeg的移動端例子:Android 視頻解碼器-單個庫版

最簡單的基於FFmpeg的移動端例子:Android 推流器

最簡單的基於FFmpeg的移動端例子:Android 視頻轉碼器

最簡單的基於FFmpeg的移動端例子附件:Android 內建播放器

最簡單的基於FFmpeg的移動端例子附件:SDL Android HelloWorld

最簡單的基於FFmpeg的移動端例子:IOS HelloWorld

最簡單的基於FFmpeg的移動端例子:IOS 視頻解碼器

最簡單的基於FFmpeg的移動端例子:IOS 推流器

最簡單的基於FFmpeg的移動端例子:IOS 視頻轉碼器

最簡單的基於FFmpeg的移動端例子附件:IOS內建播放器

最簡單的基於FFmpeg的移動端例子:Windows Phone HelloWorld

=====================================================


前幾篇文章記錄的都是IOS下基於FFmpeg的多媒體程式。本文記錄一個IOS下內建的視頻播放器。相比於移植FFmpeg來說,IOS內建的多媒體架構播放視頻要簡單很多——只需要調用幾個介面就可以了。



原始碼項目的原始碼位於ViewController.m檔案中,內容如下所示。
/** * 最簡單的IOS視頻播放器 * Simplest IOS Player * * 雷霄驊 Lei Xiaohua * leixiaohua1020@126.com * 中國傳媒大學/數字電視技術 * Communication University of China / Digital TV Technology * http://blog.csdn.net/leixiaohua1020 * * 本程式是IOS上最簡單的視頻播放器。 * This software is the simplest Video Player on IOS. * */#import "ViewController.h"#import <MediaPlayer/MediaPlayer.h>@interface ViewController ()@property (nonatomic,strong) MPMoviePlayerController *moviePlayer;//視頻播放控制器@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.        [self.moviePlayer play];        [self addNotification];    }-(void)dealloc{    //移除所有通知監控    [[NSNotificationCenter defaultCenter] removeObserver:self];}-(MPMoviePlayerController *)moviePlayer{    if (!_moviePlayer) {        NSString *urlStr=[[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:@"resource.bundle/war3end.mp4"];        NSURL *url=[NSURL fileURLWithPath:urlStr];        _moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:url];        _moviePlayer.view.frame=self.view.bounds;        _moviePlayer.view.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;        [self.view addSubview:_moviePlayer.view];    }    return _moviePlayer;}-(void)addNotification{    NSNotificationCenter *notificationCenter=[NSNotificationCenter defaultCenter];    [notificationCenter addObserver:self selector:@selector(mediaPlayerPlaybackStateChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.moviePlayer];    [notificationCenter addObserver:self selector:@selector(mediaPlayerPlaybackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];    }-(void)mediaPlayerPlaybackStateChange:(NSNotification *)notification{    switch (self.moviePlayer.playbackState) {        case MPMoviePlaybackStatePlaying:            NSLog(@"現正播放...");            break;        case MPMoviePlaybackStatePaused:            NSLog(@"暫停播放.");            break;        case MPMoviePlaybackStateStopped:            NSLog(@"停止播放.");            break;        default:            NSLog(@"播放狀態:%li",self.moviePlayer.playbackState);            break;    }}-(void)mediaPlayerPlaybackFinished:(NSNotification *)notification{    NSLog(@"播放完成.%li",self.moviePlayer.playbackState);}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}@end


運行結果App在手機上運行後的結果如所示。程式運行後,會自動播放resource.bundle中的war3end.mp4檔案。



下載
simplest ffmpeg mobile

項目首頁

Github:https://github.com/leixiaohua1020/simplest_ffmpeg_mobile

開源中國:https://git.oschina.net/leixiaohua1020/simplest_ffmpeg_mobile

SourceForge:https://sourceforge.net/projects/simplestffmpegmobile/


CSDN工程:http://download.csdn.net/detail/leixiaohua1020/8924391


本方案套件含了使用FFmpeg在移動端處理多媒體的各種例子:
[Android]
simplest_android_player: 基於安卓介面的視頻播放器
simplest_ffmpeg_android_helloworld: 安卓平台下基於FFmpeg的HelloWorld程式
simplest_ffmpeg_android_decoder: 安卓平台下最簡單的基於FFmpeg的視頻解碼器
simplest_ffmpeg_android_decoder_onelib: 安卓平台下最簡單的基於FFmpeg的視頻解碼器-單庫版
simplest_ffmpeg_android_streamer: 安卓平台下最簡單的基於FFmpeg的推流器
simplest_ffmpeg_android_transcoder: 安卓平台下移植的FFmpeg命令列工具
simplest_sdl_android_helloworld: 移植SDL到安卓平台的最簡單程式
[IOS]
simplest_ios_player: 基於IOS介面的視頻播放器
simplest_ffmpeg_ios_helloworld: IOS平台下基於FFmpeg的HelloWorld程式
simplest_ffmpeg_ios_decoder: IOS平台下最簡單的基於FFmpeg的視頻解碼器
simplest_ffmpeg_ios_streamer: IOS平台下最簡單的基於FFmpeg的推流器
simplest_ffmpeg_ios_transcoder: IOS平台下移植的ffmpeg.c命令列工具
simplest_sdl_ios_helloworld: 移植SDL到IOS平台的最簡單程式



著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.