I have a video file of in server of size 10MB, I want to play that video in iPad using mpmovieplayercontroller.
NSURL* url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSLog(#"%#",url);
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
[mp play];
The above is the code i used I am able to play the audio but not able get video in iPad simulator.
Can any one help me
Thanks
You need to add the MoviePlayerController's view as a subview to the currently visible view like this:
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
mp.view.frame = CGRectMake(0.0f, 0.0f, 768.0f, 1024.0f);
[self.view addSubview:mp.view];
[mp play];
most likely the video format is not supported. The supported video formats are: H.264, MPEG-4
Related
I've just created code for screen video capturing..its perfectly working using UIView.but if i use UIWebview than the capture screen video is displayed with stuck..I know the reason.the reason is while using web view
[[self.layer presentationLayer] renderInContext:mycontext];
is not working..and my app is crashed
so,if presentation layer is not working than video will be stuck.
and using this line
[self.layer renderInContext:mycontext];
the screen captureing is working,but video is displaying with stuck.
this is the code,while user browse any web-site in his or her mobile.
UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, 0.0);
CGContextRef mycontext = UIGraphicsGetCurrentContext();
if([[self.layer presentationLayer] respondsToSelector:#selector(renderInContext:)])
{
[[self.layer presentationLayer] renderInContext:mycontext];
}
else
{
[self.layer renderInContext:mycontext];
}
UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
while scrolling the webview and captured the video,than the capture screen video is displayed with stuck..
is there any solution?
I have code like this:
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://www.youtube.com/watch?v=_Z5-P9v3F8w");
It'll show the youtube video with the Play button, but none of the Glass gesture can make the video play. Any ideas? Thanks!
Finally figured out how to play Youtube video on Glass!
Intent i = new Intent();
i.setAction("com.google.glass.action.VIDEOPLAYER");
i.putExtra("video_url", "https://m.youtube.com/watch?v=5bWSgFnoCOk");
startActivity(i);
Using WebView can't play the video, using VideoView can only play local MP4 or streaming MP4 (there's some way to hack the MP4 link for a Youtube video, but not reliable). Also, using VideoView can only pause/play the video, but not fast forward or backward. Using the com.google.glass.action.VIDEOPLAYER above solves all the problems WebView and VideoView have.
I'm playing YouTube videos in my app - the app is Portrait only except that I'd like to have the videos play Landscape. I'm using the much publicized WebView method:
public YouTubeViewer(string url, RectangleF frame)
{
string youTubeVideoHTML = #"<object width=""{1}"" height=""{2}""><param name=""movie""
value=""{0}""></param><embed
src=""{0}"" type=""application/x-shockwave-flash""
width=""{1}"" height=""{2}""</embed></object>";
string html = string.Format(youTubeVideoHTML, url, frame.Size.Width, frame.Size.Height);
this.LoadHtmlString(html, null);
this.Frame = frame;
}
This works great except that the MoviePlayer is in Portrait orientation only. I've tried calling the WebView from within a new ViewController that supports ALL orientations, but it has no effect. I've tried rotating the WebView, but that does not affect the MoviePlayer that is magically called by the iOS.
Any help would be much appreciated.
Thanks,
Rick
The app info.plist was set to only allow Portrait orientation. Changed that and the YouTube controller correctly rotates the MoviePlayer!
I am implementing a Music related Application. In my application I need to use AVPlayer instead of MPMusicPlayer to play iPod Library songs. I used AVPlayer to support FadeIn and Fadeout effects for the background playback of MPMediaItems. I used MPMediaItemProperyAssetURL to get the url from the MPMediaItem and give it as input to the AVPlayer like follows. My problem is some items are won't play because of null url. I found that songs downloaded from iTunes store (which are DRM protected) were unable to play because they have no MPMediaItemProperyAssetURL. Could you please guys help me, how can I resolve these issues. I need to support these DRM protected songs in AVPlayer. Please take a look at my following code for reference,
MPMediaItem *currentItem = [songs objectAtIndex:songIndex];
NSURL *itemURL = [currentItem valueForProperty:MPMediaItemPropertyAssetURL];
currentlyPlayingItem=[itemURL absoluteString];
avPlayer = [[AVPlayer alloc] initWithURL:itemURL];
[avPlayer play];
Thanks in Advance,
Sekhar.
Regrettably there is no mechanism to load DRM'd files into the AVPlayer or any of the AV Foundation APIs. If you can convince your users to upgrade their entire library at $0.30 per song with iTunes Plus, that is the only way.
Ever since I updated to iOS 5, I can't get MPMoviePlayerViewController to play audio on the iPad. Video is perfect, but no audio is heard. It doesn't matter what format I use. It does not work. It works in the simulator, but not on the iPad.
- (IBAction)playVideo {
NSString *filepath = [[NSBundle mainBundle] pathForResource:#"test" ofType:#"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter]
addObserver:self selector:#selector(movieFinishedPlaying:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:[moviePlayer moviePlayer]];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
}
Anyone else have this problem? Or found a fix?
It sounds silly, but we came across an issue on my team where the volume control for general iPad sounds was muted and this meant that there was no sound for video played in our app, even though music played through the music player or video on websites worked fine.
To check this volume control you can bring up the task manager (double-tap the home button) and then swipe across to the far left and there are some music controls; check that the mute button on this screen is not on.
try this:
...
moviePlayer.useApplicationAudioSession = NO;
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
set audio session before allocating MPMoviePlayerController will play sound along with video
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayback error:nil];
moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
Ensure the audio format in the video file is something that the iPad can play. I believe the simulator has access to the host machine's codecs, which might explain why the iPad can play the video but not the audio. As noted on this page in the MPMoviePlayerController documentation:
If you use this class to play audio files, it displays a white screen with a QuickTime logo while the audio plays. For audio files, this class supports AAC-LC audio at up to 48 kHz, and MP3 (MPEG-1 Audio Layer 3) up to 48 kHz, stereo audio.
I just made the slide button on the side into lock screen. Then the sound suddely worked.