IPhone video player operations

Source: Internet
Author: User

IPhone video playerThe implementation operation is the content to be introduced in this article.Play video on iPhoneFor example, the iPhone unofficial SDK is used.

Main. m:

 
 
  1. int main(int argc, char *argv[])  
  2. {  
  3.     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];  
  4.     int ret = UIApplicationMain(argc, argv, [SimpleMoviePlayerApp class]);  
  5.     [pool release];  
  6.     return ret;  

SimpleMoviePlayer. h:

 
 
  1. #import <UIKit/UIKit.h> 
  2. #import <GraphicsServices/GraphicsServices.h> 
  3. #import <MoviePlayerUI/UIEventObservableWindow.h> 
  4. #import <MoviePlayerUI/UIMovieView.h> 
  5. #import <MoviePlayerUI/UIMoviePlayerController.h> 
  6. @interface SimpleMoviePlayerApp : UIApplication  
  7. {  
  8.  UIEventObservableWindow *mainWindow;  
  9.  UIMoviePlayerController *playerController;  
  10. }  
  11. @end 

SimpleMoviePlayer. m

 
 
  1. #import "SimpleMoviePlayerApp.h"  
  2. @implementation SimpleMoviePlayerApp  
  3. - (void)applicationDidFinishLaunching:(GSEventRef)event;  
  4. {  
  5.  struct CGRect mainFrame = CGRectMake(0,0,320,480);  
  6.  mainWindow = [[UIEventObservableWindow alloc] initWithContentRect:mainFrame];  
  7.  playerController = [[UIMoviePlayerController alloc] initWithPlayerSize:[UIHardware mainScreenSize] isFullScreen:YES];  
  8.  [[playerController playerView] setCanShowControlsOverlay:YES];  
  9.  [playerController setControlsOverlayVisible:YES disableAutohide:NO animate: YES];  
  10.  [playerController setAutoPlayWhenLikelyToKeepUp:YES];  
  11.     [playerController setDelegate:self];  
  12.  [playerController prepareAndSetupUI];  
  13.  [[playerController movieView] setMovieWithPath:@"http://192.168.0.2/video.m4v"];  
  14.  [mainWindow setContentView:[playerController playerView]];  
  15.     [mainWindow orderFront:self];  
  16. }  
  17. - (void)moviePlayerDidFinishPlayback: (UIMoviePlayerController *)player userExited: (BOOL)userExited  
  18. {  
  19.  NSLog(@"player normal exit");  
  20.  [self terminateWithSuccess];  
  21. }  
  22.  
  23. - (void)applicationWillTerminate;  
  24. {  
  25.  NSLog(@"app normal exit");  
  26.  [playerController release];  
  27.     [mainWindow release];  
  28. }  
  29. @end 

You can download the source code:

Summary:IPhone video playerThe implementation operation is complete. I hope this article will help you!

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

Related Article

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.