MPMoviePlayerController with a Custom Button on its toolbar - iphone

You might have seen video through you tube in iPhone.
Normal MPMoviePlayerController has previous, next & play/pause buttons.
You tube - player has additional two buttons on it.
=> Add to favorites on the left side.
=> Email this video on right side.
I want to implement the same for my application.
But I am failed to find out the property or methods regarding - implementing this.
How do I need buttons on it?
When User is watching video there should no buttons on screen.
When user taps on video - a toolbar comes on top & at center
A center tool bar has generally three buttons on it ,Previous - next -play/pause
I want to add a button beside next button & previous button.

I don't think you can modify the interface of an Apple provided view.
The general approach would be to play your video and then after it's done, show a view with the desired buttons/and or options for the user.
An example of this can be seen with the YouTube app on the iPhone. After the youtube video plays, the user is sent to a summary view with links to watch the video again, favourite it, share it, etc.

I would say that it may be possible to just set the MPMoviePlayerController's movieControlMode property to MPMovieControlModeHidden and add a subview to it with your own collection of buttons, titles, etc... But MPMoviePlayerController inherits only from NSObject, so you couldn't do that. Perhaps you can subclass MPMoviePlayerController and setup your own stuff when play is called, yet again, I imagine MPMoviePlayerController would display itself as a modal fullscreen view and hide anything you setup. :-\
If all you're looking to do is mess with the look of the controls, I DO know that you can mess around with various objects' drawRect: methods to override how bars and buttons are drawn.
For example, setting up a category or subclass of UINavigationBar and implementing drawRect: as follows will result in a custom navigation bar being drawn:
- ( void )drawRect:( CGRect )rect
{
[ [ UIImage imageNamed:kSTNavigationBarBackgroundImageName ] drawInRect:CGRectMake( 0.0, 0.0, self.frame.size.width, self.frame.size.height ) ];
}
This replaces Apple's standard look for their navigation bars and replaces it with a custom image asset. We do this, among other things, for our apps.

Related

customising MPMovieplayer

In my new app,I have to show videos in MPMovieplayer.Client gave me the design as in screenshot
I want to know whether it is possible to customize like this(including the top like,skip buttons and the custom slider)
If it is possible,help me to learn more about that
You can do it pretty easily with AV Foundation specifically AVPlayer class, it is the framwork underneath MPMoviePlayer. It will give you the options to have an abstract video/audio player and you'll be able to create you own customize UI
Here's an example code to start with AVPlayer
AVPlayer will work, but I hear it can be more complicated than working with a more higer level solution like MPMoviePlayer. I've been working on making my own customized UI for a video stream using MPMoviePlayer.
Whenever you create your MPMoviePlayer object, just set control style to none with: MPMovieControlStyleNone this leaves your video player ready for you to make customize controls. I suggest using a UIToolbar and then setting UIBarButtonItems onto your toolbar. Once your toolbar has all your buttons, add the toolbar to the subview with the addSubview method. You can then add functionality to the buttons and slider with the MPMediaPlayback Protocol with methods like play and pause. By the way, the top like and skip buttons could just be UIButtons which are pretty customizable. Lastly, if you want the controls to disappear on a tap then look into Gesture Recognizers.
Of course you can style your buttons and position your toolbar as needed, but this should get you a basic start.
Here's a custom class I wrote that works in iOS6 and newer.
https://github.com/busterbooth/bbMoviePlayer
You can control and re-skin just about every aspect of the MPMoviePlayer as long as you do the following.
MPMoviePlayerController *mp= [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:#"http://example.com/video.file"]];
mp.controlStyle = MPMovieControlStyleNone;

How to Display Custom View Modaly

I've written a small multiplayer game for the iphone. Once one of the players win, I want to display him 'You Win' image and a button so that he can play again.
How can this be done? One option is to use a segue to a new view-controller, but I think this should be shown with the game in the background. What would you suggest, as I'm pretty sure this is a common scenario for an iphone game/app.
EDIT: I ended up using both Phillip Mills's answer and Selkie's answer. Here is on How to Use UIView transitionWithView?
You can create the custom view and keep it as a separate property within your main game view controller. When someone wins, add it as a subview to the view property of the controller. It can be full screen size with transparency so that it's effectively modal, yet shows the game as background.
You can make it as a view, then show it using UIView animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
The animation block could be sliding up, fading or whatever you want.
The other way is to add it at the beginning, but set its hidden property as YES. Change it to NO when it's needed.

How does Facebook iPhone app implement the pop-over window for notifications?

How does Facebook iPhone app (4.1) implement the pop-over window for notifications (see below for screenshot)? I thought this was only capable on the iPad. Is this a lookalike that they have custom built?
Check out this library which can implement pop over menus like facebook app: https://github.com/50pixels/FPPopover
I think it is far more complicated (and cleaner) than either of answers (guesses) so far. It is likely a completely separate view controller with it's own content view that is being added as a subview of the container view.
There are some libraries that so a similar thing, here is one for example:
https://github.com/KJoyner/SeaGlass/wiki/SGPopoverController-Documentation
http://www.facebook.com/note.php?note_id=107632999326583
https://github.com/chrismiles/CMPopTipView
My first guess would be that the "popover" is just a subview within the mainview.
First you create the subview, then hide it mySubView.hidden = TRUE; . When the user taps on the Globe button just "unhide" mySubView.hidden = FALSE; the subview with a nice 1 second animation (which will make it fade in).
I imagine that the edges with the rounded corners, subtle inner glow, and outer shadow are part of a resizable 9 part image. From there, it just about placing it on screen stretching it out and drawing the arrow at the appropriate location to line up with the bar button item.

Customized Camera Toolbar on iPhone

I've created a camera application for iPhone and now I sit and polish the last of it. My application is a collage application where the user can take multiple pictures in a row.
As it is today I have a customized camera view that contains one UIButton for taking the pictures and one UIButton for getting back to the main view.
The problem is that my application is design for landscape mode and the camera control can only show in portrait mode. This makes the design of the GUI a little bit tricky and I now want to move away from having the buttons in the view to having the placed in a toolbar. When you initialize the camera you can set a bunch of different parameters and one of them is UIImagePickerController.toolbarHidden. If I set the value to NO it will show an empty toolbar and my question here is, how do I add items to this toolbar?
I've tried different solutions without any luck.
Thanks,
drisse
Does the standard UIViewController method -setToolBarItems:animated: method not work?

UIButton Game character selection to UIImageView animation

I am almost at the end of coding my kids educational application, woohoo!.
But... Im stuck on something.
When app loads i have my main view. It has 4 buttons for flipviews(each with ten views of content) and 4 buttons for character selection(an image that will follow you through every screen of content).
Problem is im unsure on how to link UIButton selection to UIImage display in multiple views. I want the user to choose a character button and then continue to the flipviews and in the views the image displayed should be the one that they have selected on the main view. So everytime they return to the main view they can change the character that will follow them around the app.
Any thoughts, help or code would be much appreciated!
Thank You
Alex
Make a new object, a subclass of UIImageView, which has a -setImage method. Once you set the image, then where ever you embed that object, it will display the same image. You could even have that subclass view have a score displayed next to it, or a name or other stats, so as you go from one screen to another, you have all that info follow you around with the image. No need to create labels in all the screens for global info like that.
In summary:
make a new subclass of UIView or UIImageView in Xcode using the New File... menu. You would do new UIView if you will have other items than just an image.
add methods that allow you to set the image, update text stats etc.
BONUS: you can make the class handle taps, so if a user taps the image, you could do something like provide help or run a cute little animation
embed that object in any screens you wish. Keep in mind that you can have that view be sized differently in each screen using transforms. Cool, no?
that's pretty much it!
Good luck!