IPhone video player demo & source code

Source: Internet
Author: User

This article is an example of using an iPhone to play a video, using an unofficial iPhone SDK.

 

The author of the Code is hobbut.

Original article address (Russian): http://blog.weho.ru/2008/04/primer-prostogo-videopleera.html

Main. M:

 

Int main (INT argc, char * argv [])

{

NSAID utoreleasepool * Pool = [[NSAID utoreleasepool alloc] init];

Int ret = uiapplicationmain (argc, argv, [simplemovieplayerapp class]);

[Pool release];

Return ret;

}

 

 

Simplemovieplayer. h:

 

 

# Import <uikit/uikit. h>

# Import <graphicsservices/graphicsservices. h>

# Import <movieplayerui/uieventobservablewindow. h>

# Import <movieplayerui/uimovieview. h>

# Import <movieplayerui/uimovieplayercontroller. h>

 

@ Interface simplemovieplayerapp: uiapplication

{

Uieventobservablewindow * mainwindow;

Uimovieplayercontroller * playercontroller;

}

 

@ End

 

Simplemovieplayer. m 

# Import "simplemovieplayerapp. H"

 

@ Implementation simplemovieplayerapp

 

-(Void) applicationdidfinishlaunching :( gseventref) event;

{

 

Struct cgrect mainframe = cgrectmake (0,0, 320,480 );

 

Mainwindow = [[uieventobservablewindow alloc] initwithcontentrect: mainframe];

 

Playercontroller = [[uimovieplayercontroller alloc] initwithplayersize: [uihardware mainscreensize] isfullscreen: Yes];

[[Playercontroller playerview] setcanshowcontrolsoverlay: Yes];

[Playercontroller setcontrolsoverlayvisible: Yes disableautohide: No Animate: Yes];

[Playercontroller setautoplaywhenlikelytokeepup: Yes];

[Playercontroller setdelegate: Self];

[Playercontroller prepareandsetupui];

[[Playercontroller movieview] setmoviewithpath: @ "http: // 192.168.0.2/video. m4v"];

 

[Mainwindow setcontentview: [playercontroller playerview];

[Mainwindow orderfront: Self];

}

 

-(Void) movieplayerdidfinishplayback: (uimovieplayercontroller *) player userexited: (bool) userexited

{

Nslog (@ "Player normal exit ");

[Self terminatewithsuccess];

}

 

-(Void) applicationwillterminate;

{

Nslog (@ "app normal exit ");

[Playercontroller release];

[Mainwindow release];

}

 

@ End

 

You can download the source code here.

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.