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