I want to play videos. I am using MPMoviePlayer, but I don't want to use the controls provided by MPMoviePlayer. So I am trying to create my own custom controls. All the functionality like play, pause, fullscreen, forward, backward are done. The only problem is with the scrubber. I am having one UISlider but I don't know how exactly work with this. How to track the currently playing video time? How to play video from where I will slide the thumb of slider?
If anyone knows this kindly help me in this.
Thanks in advance.
I was having a similar problem. I figured out how to create custom movie controls and put it up on github. Let me know if that helps. Feel free to ask me any questions if you want details.
First, we should note that all of this is possible in iOS 3.2+, if you are OK not to support iOS 3.1.x.
In iOS 3.2+, MPMoviePlayerController implements the MPMediaPlayback protocol, meaning that it responds to play, stop, etc., all the controls you would expect -- sounds like you already have some of this working. Please see the reference for the MPMediaPlayback protocol.
To get the MPMoviePlayerController to stop showing its own controls, do this on initialization:
yourPlayer.controlStyle = MPMovieControlStyleNone;
Finally, to get the scrubber to work, you need to set the UISlider valueChanged: callback to something, and update the value of currentPlaybackTime property. If you want to seek 10 seconds in:
yourPlayer.currentPlaybackTime = 10;
Related
I have a UIPickerView in my app in which the 'tick' sound when moving from one index to the next is not played. I swear it used to play the sound, but recently it has not played.
I am using custom labels for each item in the picker, and I tried commenting that out and the sound still does not play.
I have searched around and saw there is a method [pickerView setSoundsEnabled:YES], but it is a private API, so I cannot use that.
Most threads I have found are people trying to stop the sound from playing, shouldn't it be playing the sound by default?
Any help appreciated, thanks.
I believe this sound is set/unset via the system-level preferences panel, Settings->Sounds->Keyboard Clicks->On, and cannot be set at the API level (at least, not officially).
The issue ended up being with using the FMOD library. I filed a bug report, it was when using the PLAY_AND_RECORD filter.
I am streaming a movie to MPMoviePlayerController by simply passing MPMoviePlayerController the URL of the movie file. I am using my own custom controls and would like to create a progress bar to see how much of the video has been buffered (like in YouTube) . But there doesn't seem to be any available data
to create this. Does anyone know how to do this. Thanks.
Prior to iOS 5.x the playableDuration did the job. But since iOS 5 this property seem to always return zero. Give it a try and please let me know if it does work for you.
If I use MPMoviePlayerController to play video in my iPhone app, it opens, loads the movie, plays it and then closes. Is it possible to force it to stay open after the movie finishes, so that user can replay it using its controls, instead of using controls in parent view? Also, is it possible to start MPMoviePlayerController in the paused mode?
thanks for any advice.
None of that is possible using the available API in the Pre-3.2 OS. One thing you could do is take a scerenshot of the last frame and stick that behind the movie so when it's done playing, it looks like it's still there, then just stick a button on it to replay. you could make an interface that looks/behaves similar to the standard movie player interface just for the play button if you need to.
For anyone stumbling over this now... There is a way to do this. Check out this question :)
I was trying to go through the iPhone's sample code for mediaplayer.
I want to be able to capture the amount of time the media player has played the video. The duration at which the media player has stopped. Is there a method or property that will tell me the duration of play of the media??
Unfortunately the current API for MPMoviePlayerController allows basically no control. You can tell it to play and stop... otherwise where's a delegate method so you can be notified when the movie finishes playing and that's it, there's no additional controls. (a real bummer)
However, while we cant discuss the new 3.2 SDK yet, I'll give you a tip and say go look at the documentation of MPMoviePlayer in 3.2 and I think you'll be happy.
http://developer.apple.com/iphone/prerelease/library/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html
moviePlayer.currentPlaybackTime
It's not possible to do KVO on it but you could do like me and create an scheduledTimer which updates every second to check what the current playbacktime is and update your graphics accordingly :)
Yes, You can use the property "duration" defined by MPMediaPlayerController. Plese try it out and check the output. U can refer the here duration property
I am implementing a sound effect that plays while a user is dragging a UISlider.
Here is the IBAction: called by the UISlider's Value Changed event
-(IBAction)playTone4; {
AudioServicesPlaySystemSound(soundID4);
}
I would like the sound to halt when the user is not dragging the slider but has not released it.
Is there a way to do that? There doesn't seem to be an AudioServicesStopSystemSound() function.
System sounds cannot be stopped.
See the iPhone Programming Guide: section Multimeda Support for more information.
To accomplish the desired effect, I would recommend using AVAudioPlayer or audioQueues. The Programming Guide I addressed covers everything you want to know about these techniques.