views:

144

answers:

1

Hi Guys, This is my code for load the video using MPMoviePlayerController my issue is i can hear the voice of the video but can't see the video. can any one give me the solution!!!

note:"AddRunningClient starting device on non-zero client count" this message is display while i run my application in console

now i'm working IOS4.1 sdk

   - (void)viewDidLoad {
     [super viewDidLoad];

     NSString *mediaPath = [[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:@"understandingoilcost_1500kbps.mov"];

    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:mediaPath]];

    moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

    [moviePlayer play];
}

Please help me out!

Thanks.

+2  A: 

That's because you haven't added the player's view to your view. You need to do something like this:

[[moviePlayer view] setFrame:[[self view] bounds]];
[[self view] addSubview: [moviePlayer view]];

Also, you should store the movie player in an instance variable, or else you won't be able to stop it or release it (thus creating a memory leak).

DarkDust
hai thanx for quick reply i tried you code but NSLog(@"loadView") printed in console continously without stop. and also [self addSubView:[moviePlayer view]]; is not support in my sdk
sri
See edited version of my answer... I've missed that this inside a UIViewController instead of an UIView.
DarkDust
hai thank you but in console 2010-10-13 17:23:12.585 Video[1714:207] loadView2010-10-13 17:23:12.592 Video[1714:207] loadView2010-10-13 17:23:12.601 Video[1714:207] loadView this will display continously without starting the application
sri
That's an unrelated problem outside your view controller. Set a break point in loadView and look who's calling it.
DarkDust
Thanx finally i got the answer its work fine :)
sri