How to Speed up the audio Playing in MpMoviePlayerController - ios

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.

Related

Adjust Quality while streaming video with AVPlayer

How can I able to set low or high quality video withstreaming video with AVPlayer?
My code is as follow:
self.videoPlayerItem = [AVPlayerItem playerItemWithURL:videoUrl];
videoPlayer = [AVPlayer playerWithPlayerItem:self.videoPlayerItem];
videoPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
CGRect frame = self.frame;
videoPlayerLayer = [AVPlayerLayer layer];
[videoPlayerLayer setPlayer:videoPlayer];
[videoPlayerLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
Thanks for your time
You can lower the video quality/bitrate by setting AVPlayerItem's preferredPeakBitRate.
Re-set it to zero to get the usual "highest quality/bitrate supported by your connection" behaviour.
N.B. A bitrate less than or equal to preferredPeakBitRate must be available for this to work, e.g. in an HLS stream.

Play audio in background (play when using other APP)

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];

Display MPMoviePlayerController during media loading

I use a MPMoviePlayerController to play audio (ex: http://www.stanford.edu/group/edcorner/uploads/podcast/ballmer090506.mp3) or video (ex: http://video.ted.com/talk/podcast/2011U/None/RicElias_2011U.mp4)
myMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theURL];
myMoviePlayer.view.frame = CGRectMake(-80, 80, 480, 320);
myMoviePlayer.controlStyle = MPMovieControlStyleFullscreen;
myMoviePlayer.movieSourceType = MPMovieSourceTypeFile;
myMoviePlayer.scalingMode = MPMovieScalingModeAspectFit;
myMoviePlayer.useApplicationAudioSession = TRUE;
[myMoviePlayer prepareToPlay];
[myMoviePlayer play];
It works well, my only one problem is during the loading time (between 5s and 20s if I have a bad 3G reception), I have a black screen.
I would like to have MPMoviePlayerController diplayed with the "Loading..." label and the UIActiviyIndicator in his top bar during this time, like YouTube videos.
How can I do that?
Thanks.
Just use MPMoviePlayerViewController instead of MPMoviePlayerController. It should do what you want.

How to reset the content URL for MPMoviePlayerController when playing a video?

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.

MPMoviePlayerController control visible when starting movie

I have strange problem with MPMoviePlayerController. When movie starts , top bar with done button & controls remain visible for few seconds.Then disappears.
I am using
[player setControlStyle:MPMovieControlStyleFullscreen];
[player setFullscreen:YES];
player is an object of MPMoviePlayerController
I just want movie to play in full screen with top bar & controls hidden
& become visible only if user taps the screen
I am using iOS 4.0
try this
before starting the video
player.controlStyle = MPMovieControlStyleNone;
and when movie starts playing then set
player.controlStyle = MPMovieControlStyleFullscreen;
You can get play callback from MPMediaPlayback protocol.

Resources