SvenTiigi / YouTubePlayerKit

A Swift Package to easily play YouTube videos 📺
https://sventiigi.github.io/YouTubePlayerKit/
MIT License
717 stars 64 forks source link

Add a fade time to the volume setting #16

Closed tcarroll2 closed 2 years ago

tcarroll2 commented 2 years ago

Motivation

ℹ Apple implements a volume fade time for their AVAudioPlayer.

Solution

ℹ Recommend implementing a volume fade capability that continuously modifies the player volume over the period of time (seconds) from the current volume to the new volume level through the implementation of a timer function. AVFoundation implements a setVolume method on the AVAudioPlayer that takes a volume level and time in seconds. If the time value is 0, then the volume is adjusted to the level value immediately. But, if a time value greater than zero is specified the volume is adjusted to the new level over that period of time in seconds.

Additional context

ℹ In my app I want to seek to a specific point of a video to begin playback and only play it for a limited amount of time and then fade before loading the next video and repeat the process.

SvenTiigi commented 2 years ago

Hey @tcarroll2,

Thanks for your feature requests.

The YouTube Player iFrame API only accepts integer based values when retrieving or changing the volume. Therefore changing the volume over time is not easily possible as the corresponding Double value that could be used to incrementally change the volume over the given fade duration would not be accepted by the YouTube Player iFrame API.

Please feel free to open up a PR ✌️

SvenTiigi commented 2 years ago

Closing this issue due to inactivity. Feel free to re-open the issue at any time.