Primary knowledge and use of streaming media in IOS

Source: Internet
Author: User

1. Streaming media refers to the use of streaming technology in internet/intranet for continuous time-based media, such as audio, video or multimedia files. Streaming media does not download the entire file before playback, only the beginning of the content into memory, streaming media stream at any time to play, but at the beginning of some delay. The key technology of streaming media implementation is streaming.

2. The streaming address here refers to the video stream that has been formatted on the server side that can be played on iOS.

Example: Http://www.jxvdy.com/file/upload/201309/18/18-10-03-19-3.mp4

3.iOS Movies Play MediaPlayer and Avplayer (framework)

At iOS developers, if you're going to encounter a movie, such as a boot animation, we're accustomed to using MediaPlayer to play the movie, because it's easy to use, so keep using it. But the more demanding the customer is, the more serious it is, especially when it comes to the animation or interaction effect. So if you gimps with a film in some of the animations, the machine will not run. So after iOS 4, we can use Avplayer to do a more subtle operation.

Note:

    • MediaPlayer's film is placed in the UIView, and Avplayer is placed in Avplayerlayer, Avplayerlayer is the sub-category of Calayer.
    • Before using MediaPlayer, remember to join Mediaplayer.framework and #import <MediaPlayer/MediaPlayer.h>
    • Before using Avplayer, remember to join AVFOUNDATION.FRAMEWORKK and #import <AVFoundation/AVFoundation.h>

Please refer to the following example:

Use MediaPlayer to play a movie

NSString *filepath = [[NSBundle mainbundle] Pathforresource:@"BACKSPACE"OfType:@"mov"]; Nsurl*sourcemovieurl =[Nsurl Fileurlwithpath:filepath]; MoviePlayer=[[MPMoviePlayerController alloc] initwithcontenturl:sourcemovieurl]; MoviePlayer.view.frame=cgrectmake (0,0,1024x768,768); Movieplayer.controlstyle=Mpmoviecontrolstylenone; //Play the movie![Self.view AddSubview:moviePlayer.view];

Use Avplayer to play the movie:

NSString *filepath = [[NSBundle mainbundle] Pathforresource:@"BACKSPACE"OfType:@"mov"]; Nsurl*sourcemovieurl =[Nsurl Fileurlwithpath:filepath]; Avasset*movieasset =[Avurlasset Urlassetwithurl:sourcemovieurl Options:nil]; Avplayeritem*playeritem =[Avplayeritem Playeritemwithasset:movieasset]; Avplayer*player =[Avplayer Playerwithplayeritem:playeritem]; Avplayerlayer*playerlayer =[Avplayerlayer Playerlayerwithplayer:player]; Playerlayer.frame=Self.view.layer.bounds; Playerlayer.videogravity=Avlayervideogravityresizeaspect;    [Self.view.layer Addsublayer:playerlayer]; [Player play];

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.