Video live in iOS-streaming media usage (detailed) Han Junqiang's CSDN Blog

Source: Internet
Author: User

Previous blog: (Streaming media to achieve video playback and download function): http://blog.csdn.net/qq_31810357/article/details/50574914

The recent video broadcast function compared to fire, in demand, research, according to the analysis of the decision to use streaming media implementation, code easy to understand, next look at the tutorial:

Daily Update Attention :http://weibo.com/hanjunqiang Sina Weibo

Brief introduction:

HLS protocol: >5M will be AppStore rejected server requirements low latency High multi platform
RTMP protocol: TV Live PC side with flash plug-in good timeliness need to transcode FFmpeg delay 200msRTSP protocol: Camera function
Soft decode: FFmpeg hard decode: iOS8 after Videotoolbox frame

Tutorial Preparation:

Download third-party support:Vitamio GitHub Address: Https://github.com/yixia/Vitamio-iOS.git

1. Drag into the project:

Daily Update Attention :http://weibo.com/hanjunqiang Sina Weibo

2. Add a dependent library:



3. Modify the configuration information (double-click Input-OBJC):

Note: The-OBJC of the input is capitalized on the other lowercase, and the wrong one will cause the run crash

Daily Update Attention :http://weibo.com/hanjunqiang Sina Weibo

4. Code section:

Created by Hanjunqiang on 16/6/5.//copyright©2016 year HaRi. All rights reserved.//#import "ViewController.h"//http://wow01.105.net/live/virgin1/playlist.m3u8//http:// ivi.bupt.edu.cn/hls/cctv1hd.m3u8 C1 HD//http://ivi.bupt.edu.cn/hls/cctv3hd.m3u8 C3 HD//http://ivi.bupt.edu.cn/hls/ cctv5hd.m3u8 C5 HD//http://ivi.bupt.edu.cn/hls/cctv5phd.m3u8 c5+ HD//http://ivi.bupt.edu.cn/hls/cctv6hd.m3u8 C6 HD// http://ivi.bupt.edu.cn/hls/cctv8hd.m3u8 C8 HD//http://ivi.bupt.edu.cn/hls/chchd.m3u8 chc HD movie//http:// IVI.BUPT.EDU.CN/HLS/BTV6HD.M3U8 Beijing Sports HD//http://ivi.bupt.edu.cn/hls/hunanhd.m3u8 Hunan HD//http://ivi.bupt.edu.cn/hls /zjhd.m3u8 zhejiang HD//http://ivi.bupt.edu.cn/hls/gdhd.m3u8 Guangdong HD//http://ivi.bupt.edu.cn/hls/tjhd.m3u8 Tianjin HD # define kmvadress @ "http://wow01.105.net/live/virgin1/playlist.m3u8" #import "VMediaPlayer.h" @interface Viewcontroller () <VMediaPlayerDelegate> @property (nonatomic, strong) Vmediaplayer *vplay; @end @implementation viewcontroller-( void) dealloc{[_vplay Unsetupplayer];} -(void) Viewdidload {[Super Viewdidload];    _vplay = [Vmediaplayer sharedinstance];        [_vplay SetupPlayerWithCarrierView:self.view withdelegate:self];    Nsurl *vurl = [Nsurl urlwithstring:kmvadress];    [_vplay Setdatasource:vurl Header:nil];    [_vplay Prepareasync]; }//when ' player is ready to complete ', the protocol method is called, where we can call [player start]//to start the playback of the audio and video.-(void) MediaPlayer: (Vmediaplayer *) player didprepared: ( ID) arg{[player start];} When ' The audio and video is finished ', the protocol method is called, we can do some player aftercare//operation, such as: Reset the player, ready to play the next audio and video, etc.-(void) MediaPlayer: (Vmediaplayer *) player Playbackcomplete: (ID) arg{[player reset];} If playback fails due to an error for a reason, the Protocol method is called and the parameter//number ARG contains the cause of the error.-(void) MediaPlayer: (Vmediaplayer *) Player error: (ID) arg{NSL OG (@ "NAL 1RRE &&&& vmediaplayer Error:%@", Arg);}    -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} @end

Final effect:


If you have good advice or questions, please follow us on Weibo:

Daily Update Attention :http://weibo.com/hanjunqiang Sina Weibo


Video live in iOS-streaming media usage (detailed) Han Junqiang's CSDN Blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.