Skip to main content
Home

Main navigation

  • Apps
  • Forum
  • Blog
    • Podcast
    • Guides
    • Hardware & Accessory Reviews
    • Bug Tracker
    • Developer Resources
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. App Development and Programming

How to tie Voiceover into an MPVolumeView Slider?

By Mane, 27 February, 2018

Forum
App Development and Programming

I created an MPVolumeView slider in Interface Builder to adjust the audio volume (code below):

import UIKit

import MediaPlayer

class StreamVolumeTableViewCell: AudioStreamTableViewCell

{
static let identifier = "StreamVolumeTableViewCell"

override func awakeFromNib() {

super.awakeFromNib()

self.volumeSlider.setRouteButtonImage(UIImage(named: "black_route_button"), for: .normal)

self.volumeSlider.showsRouteButton = false

}

@IBOutlet var volumeSlider: MPVolumeView!
}

Now I want to make it accessible and tie in Voiceover.

I enabled accessibility on the slider, set its label ("Sound volume."), and set the 'User Interaction Enabled', 'Adjustable', and 'Allows Direct Interaction' traits. When I turn Voiceover on, it speaks the label and default hint, BUT --- when I swipe up and down, the volume slider's value does not change.

It does not appear that my finger flicks are getting through to the slider.

Also, when I adjust the volume with the hardware buttons on an actual device, the volume changes, but no updates are spoken when VO is turned on.

How do I accomplish what I'm after?

Thanks!!!

Options

  • Log in or register to post comments

Comments

maybe

By techluver

5 years 3 months ago

I'm not amazing at swift, so forgive me if this seems weird.
VO requires standard controls to work properly. Did you actually drag a slider control into your storyboard and link it that way? Or did you design something custom?

What I did

By Mane

5 years 3 months ago

In reply to maybe by techluver

I inserted a UIView into a TableViewCell in IB, and changed its class to MPVolumeView. Then I control-dragged a line from my nib into my Swift code to create an outlet variable.

Standard components are

By splyt

5 years 3 months ago

Standard components are accessible with VoiceOver because their implementation take care of setting and dealing with accessibility properties correctly, something that does not seem to happen with your component.
You created a custom component by changing a UIView into something not related. When the screen reader finds your MPView component, it treats that as a generic UIView, because that is precisely what it is.
I have not the details about how you managed to compose components on MPView visually. But as far as VoiceOver is concerned it can not deduce that whatever you set to happen visually on that view corresponds to a slider change.
You need to inherite your new class from UIView and research how to feed the several properties that VoiceOver uses to report information back adequately. At the end this is what the standard Apple components do anyways.

Solution found

By Mane

5 years 3 months ago

As you saw, I initially created my volume slider by inserting a UIView into my interface using IB, and renaming the class to 'MPVolumeView'. After more reading, I suspected this is why Voiceover was not getting any of my flicks on the slider it created within the UIView.

I deleted the UIView and replaced it with a UISlider in IB, and renamed THAT class to 'MPVolumeView'. Now Voiceover responds as expected, getting all my finger flicks to change the slider value, and the volume changes on my device. I had to make sure the new slider-based control exposed the same outlet variable, but beyond that, I didn't have to change any of my code.

More Like This

Help Me Learn Swift + Towers of Hanoi (Forum Topic)
How to play a Voiceover notification when signal lost (i.e., no user interaction)? (Forum Topic)
How to support VoiceOver in a SpriteKit game? (Forum Topic)
Help needed in making our app accessible with VoiceOver under iOS 8 (Forum Topic)
Please tell me how to get Kindle and braille working (Forum Topic)
Looking for a specific type of social networking app (Forum Topic)
Question for swift developers about watchKit (Forum Topic)
SSleep time always go to it's default status, any ideas? (Forum Topic)

Site Information

  • About
  • Club AppleVis
  • FAQ
  • Contact

Unless stated otherwise, all content is copyright AppleVis. All rights reserved. © 2023 | Accessibility | Terms | Privacy