i want to play live streaming video in uiwebview it is playing by believe code
UIWebView *web=[[UIWebView alloc]initWithFrame:self.view.bounds];
[web loadHTMLString:htmlString baseURL:nil];
NSError *setCategoryErr = nil;
NSError *activationErr = nil;
web.scalesPageToFit=YES;
web.mediaPlaybackRequiresUserAction=NO;
[self.view addSubview: web];
but the problem is that audio is not playing in simulator or not in any device with that live video what i am doing wrong or what i have missed here
go to Info.plist property list - add a new row - select required background modes, there should be a subrow called Item 0, select app plays audio or streams audio/video using AirPlay. Also check Audio air play in background modes in compatibility.
Related
I am using MPMoviePlayerController in my app to play the video and audios. I want to give an option to user to play the audio/video slower/faster then the normal speed i.e 0.5x (slower then normal ), 1x (normal speed), 2x (double speed then normal.).
I want to know is there any way that i can speed up/down the MPMoviePlayerController streaming so that user can have options to listen/view the audio/video at slower/faster speed.
i found the solution to this problem myself.
When you use MPMoviePlayerController and make its instance then you have a property of MpMoviePlayerController as currentPlaybackRate. It is set to 1.0 by default means normal playing. If you sets its value to 1.5 or 2.0 then it will play the currently playing audio at that speed.
See the following code.
MPMoviePlayerController *moviePlayer = [MPMoviePlayerController alloc]init];
moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
moviePlayer.contentURL = #"http://someduumyUrl.com" ;
moviePlayer.controlStyle = MPMovieControlStyleDefault;
[moviePlayer prepareToPlay];
moviePlayer.currentPlaybackRate = 2.0 // will play the audio at double speed.
I created an app for streaming audio (and send mail as well) but I have a problem, my app will not keep playing after I press the home button.
I use XCODE 6.4 and the mediaplayer.framework to play the stream it is in viewcontroller and I have been activating the background mode Audio & airplay.
Can someone please let me know what I am doing wrong here, I really want to learn it.
code:
NSURL *videoStreamURL = [NSURL URLWithString:#"http://streamlink.m3u"];
_player = [[MPMoviePlayerController alloc] initWithContentURL:videoStreamURL];
_player.view.frame = CGRectMake(0, 530, self.view.frame.size.width, 38);
[self.view addSubview:_player.view];
[_player play];
Im using this code to play a commercial video in my iOS application:
- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
[videoView loadHTMLString:[NSString stringWithFormat:#"<iframe width=\"%f\" height=\"%f\" src=%# frameborder=\"1\" allowfullscreen></iframe>",frame.size.width-10,frame.size.height-10,urlString] baseURL:nil];
[self.view addSubview:videoView];
[videoView release];
}
I want to force the user to see the video and close the UIWebView once the video is completed without allowing the user to shut the video off.
I think if i can make the Video plays automatically and set the:
videoView.userInteractionEnabled = NO;
that will force the user to watch it.
My Questions:
1- How to force the UIWebView using <iframe> ?
2- How to detect if the video finished playing?
3- Is there any other way (Better One) to play YouTube videos in iOS?
Glad to hear any other ideas or answers, Thanks in advance.
try this:
videoView.userInteractionEnabled = NO;
and you can create a UIButton to close the video.
you can use LBYoutube for youtube videos. see following link
LBYouTube
I want to reset the content URL for the MPMoviePlayerController object when playing a video.
on a button click, I am setting the content URL like below,
[videoPlayer setContentURL:url];
But i am getting the "Bad Access" error.
Is there a way to change the url when a movie player is already playing a video?
It should stop the previous video and should start the video for the new url.
It means you didn't allocate memory to videoplayer
MPMoviePlayerController * videoplayer = [MPMoviePlayerController alloc] init];
[videoplayer setcontenturl: url];
it will not give you any error.
My application uses HTTP Live Streaming to play video files. We have run into a problem where as soon as the stream ends the player controls jump from the bottom of the player to the middle as seen in this screenshot (http://postimage.org/image/1dvr9u338/). Is this expected behavior and if not, any thoughts on what is happening?
If the application plays a non-live streaming video, such as an mp4, everything works fine. But as soon as we play a live-streaming video (m3u8), such as Apple's sample streaming video (http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8) this issue occurs.
The application supports iOS 4.2+ and the issue occurs on every version. I have tested this with a brand new project that just embeds an MPMoviePlayerController's view and plays the video. Below is some sample code that loads the contentURL, embeds the view, and plays the video.
- (void)viewDidLoad
{
moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:#"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]];
moviePlayerController.view.frame = CGRectMake(100, 100, 600, 400);
[self.view addSubview:c.view];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidAppear:(BOOL)animated
{
[moviePlayerController play];
[super viewDidAppear:animated];
}