Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在电影播放器中隐藏音量栏_Iphone_Ios_Mpmovieplayercontroller_Mpmovieplayer_Mpvolumeview - Fatal编程技术网

Iphone 在电影播放器中隐藏音量栏

Iphone 在电影播放器中隐藏音量栏,iphone,ios,mpmovieplayercontroller,mpmovieplayer,mpvolumeview,Iphone,Ios,Mpmovieplayercontroller,Mpmovieplayer,Mpvolumeview,如何在电影播放器中隐藏音量栏,并保持其他控件显示(播放、前进?我想显示一些没有任何声音的视频,所以音量栏完全没有用 我能做这个吗 提前感谢将MPMoviePlayer的controlStyle设置为MPMovieControlStyleNone moviePlayer.controlStyle = MPMovieControlStyleNone; 但这将隐藏视图中的所有控件 设置为MPMovieControlStyleNone后,如果要显示播放/暂停选项和搜索栏,则需要添加自定义控件。 (我以

如何在电影播放器中隐藏音量栏,并保持其他控件显示(播放、前进?我想显示一些没有任何声音的视频,所以音量栏完全没有用

我能做这个吗


提前感谢

MPMoviePlayer的
controlStyle
设置为
MPMovieControlStyleNone

moviePlayer.controlStyle = MPMovieControlStyleNone;
但这将隐藏视图中的所有控件

设置为
MPMovieControlStyleNone
后,如果要显示播放/暂停选项和搜索栏,则需要添加自定义控件。 (我以前做过,我使用滑块作为搜索栏,并将其与工具栏按钮一起放置在
UIToolBar
中。按钮用于播放/暂停选项)

MPMovieControlStyle

描述播放控件样式的常量

枚举{MPMovieControlStyleNone,MPMovieControlStyleEmbedded,
MPMovieControlStyle全屏,MPMovieControlStyleDefault= MPMovieControlStyleFullscreen};打字机 MPMovieControlStyle

常数

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
在全屏和嵌入式显示模式之间

Available in iOS 3.2 and later.

Declared in MPMoviePlayerController.h.
MPMovieControlStyle全屏

Controls for fullscreen playback are displayed. The controls include a start/pause button, a scrubber bar, forward and reverse
查找按钮,用于在全屏和嵌入式之间切换的按钮 显示模式,用于切换纵横比填充模式的按钮,以及“完成” 按钮点击“完成”按钮暂停视频并全屏退出 模式

MPMovieControlStyleDefault

Fullscreen controls are displayed by default.

Available in iOS 3.2 and later.

Declared in MPMoviePlayerController.h.

请参阅

除了“黑客”子视图之外,没有其他方法可以做到这一点。您可以将mpmovieplayervewcontroller子类化并迭代子视图。在我的一个应用程序中,我使用如下代码删除媒体控件:

- (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)
    {

    }
}

上面的代码太旧了,它与iOS 4.3兼容。在iOS 5和iOS 6上,视图层次结构发生了更改,因此您可能必须使用每个新的iOS版本更新代码。另请参见:

感谢您的回复,但正如您前面提到的,如果我使用MPMovieControlStyleNone,它将隐藏所有控件,当然我不想这样做。我只是想隐藏音量栏(和它在模拟器上显示的一样),你有其他方法吗?Thnx作为响应,关于连接的链接,我已经尝试过了,但不幸的是它不起作用,Xcode显示了一个关于MPVolumeSlider“symbol not found”的错误!我会试试你的代码,然后回来。你必须做一些反向工程来找出iOS 5或iOS 6上的类名,:-)
- (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)
    {

    }
}