Audio and video processing in iOS

Source: Internet
Author: User

Avaudioplayer: Easy to use, but only local audio files can be played, no streaming media files

Note: When loading the path of the local audio file, you cannot use nsurl *url = [Nsurl Urlwithstring:musicpath]; This sentence is to convert the network path to a URL; load local Nsurl *url = [Nsurl Fileurlwithpath:musicpath];

For example :

_player is a Avaudioplayer object that plays audio and video files, creates the player to be placed in the global, otherwise, cannot play nsstring *musicpath = [[NSBundle Mainbundle] pathforresource:@    "Music" oftype:@ "MP3";    Convert network link//Nsurl *url = [Nsurl Urlwithstring:musicpath];        Local path Nsurl *url = [Nsurl Fileurlwithpath:musicpath];    _player = [[Avaudioplayer alloc] Initwithcontentsofurl:url Error:nil];    _player.delegate = self; [_player Preparetoplay];

Avplayer: Can play local audio or stream media

_player1 is a Avplayer object that can play streaming audio nsstring *str = @ "http://www.soge8.com/1424215157/    E4eaa401acb097ad2745efe7f8213352.mp3 "; _player1 = [[Avplayer alloc] Initwithurl:[nsurl Urlwithstring:str]];

Register your system's voice:

Get file path NSString *filepath = [[NSBundle Mainbundle] pathforresource:@ "44th Street MEDIUM.CAF" Oftype:nil];        Nsurl *url = [Nsurl Fileurlwithpath:filepath];        UInt32 soundid = 0;        Register the System Sound Audioservicescreatesystemsoundid ((__bridge cfurlref) (URL), &soundid);        Playback system Sound Audioservicesplaysystemsound (Soundid); Mobile phone shake//can use Audioservicesplaysystemsound (ksystemsoundid_vibrate);



Audio and video processing in iOS

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.