Search code examples
iphonempmovieplayercontrollervolume

iphone - MPMoviePlayerController - How can I decrease volume of the video programmatically


I'm using MPMoviePlayerController to play a video which has audio as well. It's working fine. I'm hiding the default controls. So no controls are showing on the video. I want to place a slider on the video (I successfully placed a slider as well over the video). With the slider, I want to control the volume of the video that is being played. How can I control volume of video?


Solution

  • See the documentation for MPVolumeView. Here is a sample code that I use in my view controller.

    MPVolumeView *systemVolumeSlider =
        [[MPVolumeView alloc] initWithFrame: CGRectMake(10, 10, 200, 40)];
    [self.view addSubview: systemVolumeSlider];
    [systemVolumeSlider release];