0

How can I hide the volume bar in movie player and keep the other controls are appear (play, forward ... ) ? I want to show some videos that haven't any sounds, so the volume bar is totally will be useless.

can I do this ?

Thanks in advance

Muhannad Dasoqie
  • 313
  • 3
  • 17

2 Answers2

1

Set the controlStyle of the MPMoviePlayer to MPMovieControlStyleNone.

moviePlayer.controlStyle = MPMovieControlStyleNone;

But this will hide all the controls from the view.

After setting to MPMovieControlStyleNone, if you want to display the play/pause option and seek bar, You need to add custom controls. (I did it before, I used slider as seek bar and and placed it in a UIToolBar along with a Tool bar button . Button is for play/pause option)

MPMovieControlStyle

Constants describing the style of the playback controls.

enum { MPMovieControlStyleNone, MPMovieControlStyleEmbedded,
MPMovieControlStyleFullscreen, MPMovieControlStyleDefault = MPMovieControlStyleFullscreen }; typedef NSInteger MPMovieControlStyle;

Constants

MPMovieControlStyleNone

No controls are displayed.

Available in iOS 3.2 and later.

Declared in MPMoviePlayerController.h.

MPMovieControlStyleEmbedded

Controls for an embedded view are displayed. The controls include a start/pause button, a scrubber bar, and a button for toggling

between fullscreen and embedded display modes.

Available in iOS 3.2 and later.

Declared in MPMoviePlayerController.h.

MPMovieControlStyleFullscreen

Controls for fullscreen playback are displayed. The controls include a start/pause button, a scrubber bar, forward and reverse

seeking buttons, a button for toggling between fullscreen and embedded display modes, a button for toggling the aspect fill mode, and a Done button. Tapping the done button pauses the video and exits fullscreen mode.

Available in iOS 3.2 and later.

Declared in MPMoviePlayerController.h.

MPMovieControlStyleDefault

Fullscreen controls are displayed by default.

Available in iOS 3.2 and later.

Declared in MPMoviePlayerController.h.

Refer MPMoviePlayerController

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • Thanks for response, but as you have mentioned above, if I will use MPMovieControlStyleNone, it will hide all controls and for sure I don't want to make that . Just I want hide the volume bar (same it displays on the simulator), do you another approach ? – Muhannad Dasoqie Oct 31 '12 at 08:42
0

There is no way to do this except "hacking" the subviews. You may subclass MPMoviePlayerViewController and iterate the subviews. In one of my apps, I used code like this to remove things like the media controls:

- (void)removeMediaControls
{
    @try
    {
        // Search for the MPSwipeableView
        for (UIView *view1 in [self.view subviews])
        {
            // Check for the MPSwipeableView
            if ([[[view1 class] description] isEqualToString:@"MPSwipableView"])
            {
                // Search for the MPVideoBackgroundView
                for (UIView *view2 in [view1 subviews])
                {
                    // Check for the MPVideoBackgroundView
                    if ([[[view2 class] description] isEqualToString:@"MPVideoBackgroundView"])
                    {
                        // Search for the UIView
                        for (UIView *view3 in [view2 subviews])
                        {
                            // Check for the MPWildcatFullScreenVideoOverlay
                            if ([[[view3 class] description] isEqualToString:@"MPWildcatFullScreenVideoOverlay"])
                            {
                                // Search for the MPWildcatFullScreenNavigationBar
                                for (UIView *view4 in [view3 subviews])
                                {
                                    // Check for the UIImageView
                                    if ([[[view4 class] description] isEqualToString:@"UIImageView"])
                                    {
                                        // Remove the overlay
                                        [view4 removeFromSuperview];
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    @catch (NSException * e)
    {

    }
}

The code above is too old, it worked with iOS 4.3. On iOS 5 and iOS 6 the view hierarchy changed, so you may have to updated your code with every new iOS version. See also: MPMoviePlayerController hide volume slider

Community
  • 1
  • 1
Thomas Kekeisen
  • 4,355
  • 4
  • 35
  • 54
  • Thnx for response, regarding to the attached link, I have tried it but unfortunately it doesn't work, and Xcode show an error about MPVolumeSlider "symbol not found" ! I will try your code and come back – Muhannad Dasoqie Oct 31 '12 at 09:58
  • You have to do some reverse engeneering to find out the class names on iOS 5 or iOS 6, :-) – Thomas Kekeisen Oct 31 '12 at 10:18