Ch 1 17 Toggle, Sound Off + Compound Conditionals in SwiftUI (2025)

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ก.พ. 2025
  • Trickier than it looks - we'll add a toggle, left-justified in an HStack, that can turn sound play on or off. And along the way we'll learn about bindings, edge cases, .onChange, AVAudioPlayer's .isPlaying and .stop(), we'll explore the Variable View, learn nested conditionals, and compound conditionals.
    Part of a university course by Prof. John Gallaugher designed for the absolute beginner, where students will learn to program using Swift + SwiftUI. The course will move from no assumed prior programming experience while students learn fundamental, then intermediate and advanced concepts, culminating in a full stack app. Full free course playlist at:
    bit.ly/prof-g-...

ความคิดเห็น • 2

  • @SwiftCoding55-x9f
    @SwiftCoding55-x9f 13 วันที่ผ่านมา

    Can you do how to adjust sound for example like the volume as well not just sound on/off? Thanks

    • @profgallaugher
      @profgallaugher  13 วันที่ผ่านมา +1

      Yes. My assumption is most would rather use volume buttons on the device rather than a software control but you will find a volume parameter with AVAudioPlayer. It’ll be a fun exercise for you to implement this. Try learning about sliders when you do this. The values of the volume go from 0.0 to 1.0