IPhone video player example
Time:
Source:Unknown
Click:
13 times
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 address (Russian): http://blog.weho.ru/2008/04/primer-prostogo-videopleera.html main. m: int main (INT argc, char * argv []) {nut this article is an example of video playback using the iPhone, using unofficial sdks of the iPhone.
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.