I am currently trying to play a youtube video in iPad but device only display blank screen.
- (void)viewDidLoad {
[super viewDidLoad];
NSURL* videoURL = [NSURL URLWithString:#"http://www.youtube.com/......."];
MPMoviePlayerController * moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer prepareToPlay];
[moviePlayer play];
[moviePlayer.view setFrame:CGRectMake(50, 200, (self.view.frame.size.width)-100 , 400)];
moviePlayer.view.backgroundColor = [UIColor grayColor];
[self.view addSubview:moviePlayer.view];
}
This will just display a blank gray screen,But if i try to play any locally stored video file then i can able to play by MPMoviePlayerController.So what is the best way to play a youtube video in iPad.
Related
I am playing a video from Url, It is playing but very slow. I am using my mobile data.
Her is the code I play the video:
self.avPlayer = [AVPlayer playerWithURL:[NSURL URLWithString:_selectedVideo.videoLink]];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
videoLayer.frame = self.view.bounds;
[self.view.layer addSublayer:videoLayer];
[self.avPlayer play];
It is really slow and takes long time to start. Is there any way to make it faster?
Thanks
You can try mpmovieplayer to play video.
MPMoviePlayerController *player =
[[MPMoviePlayerController alloc] initWithContentURL: myURL];
[player prepareToPlay];
[player.view setFrame: myView.bounds]; // player's frame
[myView addSubview: player.view];
// ...
[player play];
I want to stream video on my iOS application, the problem is that it displays a black screen with the url I want to show but it works with other url's here is my code :
[super viewDidLoad];
NSURL *fileURL = [NSURL URLWithString:#"http://livevideo.infomaniak.com/iframe.php?stream=arabelfmendirect&name=arabel_webtv&player=2828.m3u8"];
moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[moviePlayerController.view setFrame:CGRectMake(0, 70, 320, 270)];
[self.view addSubview:moviePlayerController.view];
// moviePlayerController.fullscreen = YES;
[moviePlayerController prepareToPlay];
[moviePlayerController play];
how can I fix it ?
The video URL mentioned doesn't use HLS format. Thus MPMoviePlayerController cannot play the video.
From http://livevideo.infomaniak.com/iframe.php?stream=arabelfmendirect&name=arabel_webtv&player=2828.m3u8, it looks like it needs flash to play the video.
I am trying to play a video from url and the only thing i am getting is a black screen and a loading wheel?
I have a XML/JSON from witch i need somehow to play the video,
I tried with all 3 links i have there and no response
NSURL *url = [[NSURL alloc] initWithString:#"http://rutube.ru/play/embed/7224398"];
moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
[moviePlayer.view setFrame:CGRectMake(self.view.frame.origin.x , self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES];
[moviePlayer setShouldAutoplay:YES];
Is there a chanse to start this video using MPMoviePlayerController ??
P.S: I managed to load the video in a WebView but its not what i need.
You have to extract direct link to .mp4 file somehow.
Check this article.
I'm trying to create an app where I have a video playing within a MPMoviePlayerController. If the video gets paused, it takes a screenshot with thumbnailImageAtTime. The problem is that the image MPMoviePlayerController displays after pause and the screenshot I get with thumbnailImageAtTime aren't the same.
My code looks like this:
[self.moviePlayer pause]
[self.moviePlayer thumbnailImageAtTime:self.moviePlayer.currentPlaybackTime timeOption:MPMovieTimeOptionExact];
Screenshot
Any help is highly appreciated :)
What I used is MPMovieTimeOptionNearestKeyFrame
- (UIImage *)imageFromMovie:(NSURL *)movieURL atTime:(NSTimeInterval)time {
// set up the movie player
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc]
initWithContentURL:movieURL];
mp.shouldAutoplay = NO;
mp.initialPlaybackTime = time;
mp.currentPlaybackTime = time;
// get the thumbnail
UIImage *thumbnail = [mp thumbnailImageAtTime:time
timeOption:MPMovieTimeOptionNearestKeyFrame];
// clean up the movie player
[mp stop];
[mp release];
return(thumbnail);
}
Try this
I'm trying to use an MPMoviePlayerController on iOS to play back an audio stream over HTTP.
I've imported MediaPlayer.framework and used the code from MPMoviePlayerController's documentation, but I get no sound.
MPMoviePlayerController *player =
[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:#"http://shoutmedia.abc.net.au:10326"]];
[player prepareToPlay];
[player.view setFrame: self.view.bounds]; // player's frame must match parent's
[self.view addSubview: player.view];
[player play];
I've also tried adding player.movieSourceType = MPMovieSourceTypeStreaming; but didn't work neither.
Any thoughts?