Saturday, January 4, 2014

How to play online video iphone achieve it?

I ask my friend, how to play on the iphone it directly online video
Reply:
Online
Reply:
The reply was deleted at the moderator 2010-10-16 10:47:12

Reply:
 
- (Id) init
{
if (self = [super init])
{
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @ selector (moviePreloadDidFinish :)
name: MPMoviePlayerContentPreloadDidFinishNotification
object: nil];

/ / Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @ selector (moviePlayBackDidFinish :)
name: MPMoviePlayerPlaybackDidFinishNotification
object: nil];

/ / Register to receive a notification when the movie scaling mode has changed.
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @ selector (movieScalingModeDidChange :)
name: MPMoviePlayerScalingModeDidChangeNotification
object: nil];
return self;

}
return nil;
}



- (Void) playMovie: (Contentinfo *) info
{


if (moviePlayer! = nil)
{
[MoviePlayer release];
moviePlayer = nil;
}
NSURL * url = nil;

if ([info.pathUrl hasPrefix: @ "http://"])
{

url = [NSURL URLWithString: info.pathUrl];
}
else
{

NSString * fullPath = [DataUtil getContentFilePath: info.pathUrl];
NSLog (@ "% @", fullPath);
url = [NSURL fileURLWithPath: fullPath];
}

if (url! = nil)
{
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: url];
moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
moviePlayer.movieControlMode = MPMovieControlModeDefault;
musicIsPlaying = [[MusicPlayerEngine shareInstence] isPlaying];
if (musicIsPlaying)
{
[[MusicPlayerEngine shareInstence] pause];
}


self.Info = info;


[MoviePlayer play];
}


}

/ / Video is ready to play
- (Void) moviePreloadDidFinish: (NSNotification *) notification
{
NSArray * windows = [[UIApplication sharedApplication] windows];
if ([windows count]> 1)
{
UIWindow * moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
UIImageView * view = (UIImageView *) [moviePlayerWindow viewWithTag: LOADING_VIEW_TAG];
if (view! = nil) {
[View removeFromSuperview];
}
}


if (0 == [[notification userInfo] count])
{/ / Set the system time to contentInfo object
NSString * a = [NSString stringWithString: [self getTime]];
Info.lastPlayedTime = a;
/ / Add contentInfo object to the recently played list
[[DataBase sharedInstance] addContentInfoToRecentPlayList: self.Info];
}

NSLog (@ "moviePreloadDidFinish");
}
/ / Video has played end
- (Void) moviePlayBackDidFinish: (NSNotification *) notification
{
NSLog (@ "moviePlayBackDidFinish");



if (musicIsPlaying) {
[[MusicPlayerEngine shareInstence] playMusic];
}
After / / begin zhaozhou mv player interface exit, refresh recent player interface
[Self.delegate reloadRecentPlayTableView: self];
/ / End

}
/ / Video proportional mode change.
- (Void) movieScalingModeDidChange: (NSNotification *) notification
{
NSLog (@ "movieScalingModeDidChange");

}

No comments:

Post a Comment