pocket-casts-ios
pocket-casts-ios copied to clipboard
Sleep Timer: automatically restart if playback is resumed within 5 minutes
This PR implements a mechanism to restart the sleep timer whenever the user restarts playback within 5 minutes.
- The sleep timer will restart with the same configuration as before (same time or end of episode)
- If playing after more than 5 minutes, the sleep timer should not restart
I haven't added any confirmation sound because if I'm sleeping I don't feel like hearing a voice or a confirmation sound for the sleep timer, but we can adjust accordingly in the future based on feedback.
To test
To make testing faster, go to SleepTimerViewController.swift
and change the fiveMinutesTapped
function to 5.seconds
(instead of 5.minutes
), also go to Profile > Beta Features > and enable tracksLogging
.
Restarting timer for a given amount of time
- Run the app
- Add 5 to 10 podcasts to your Up Next
- Play something
- Open the full player, tap the sleep timer icon (zZz), select 5 minutes (in our case it will be 5 seconds)
- After 5 seconds the playback should stop
- Tap play again
- ✅ The sleep timer should restart with 5 seconds
- ✅ Ensure
🔵 Tracked: player_sleep_timer_restarted ["duration": 5.0]
is tracked
Not restarting timer
Go to SleepTimerManager.swift
and change restartSleepTimerIfPlayingAgainWithin
to 5.seconds
.
- Play something
- Open the full player, tap the sleep timer icon (zZz), select 5 minutes (in our case it will be 5 seconds)
- After 5 seconds the playback should stop
- Wait for 10 seconds
- Tap play again
- ✅ The sleep timer should not restart
Restarting timer for end of episode
Go to SleepTimerManager.swift
and revert restartSleepTimerIfPlayingAgainWithin
to 5.minutes
.
- Play something
- Open the full player, tap the sleep timer icon (zZz), select end of episode
- Drag the scrubber close to the end of the episode and wait till it's finished
- Tap play again
- ✅ The next episode should play and sleep timer should restart for end of episode
- ✅ Ensure
🔵 Tracked: player_sleep_timer_restarted ["duration": "end_of_episode"]
is tracked
Pausing
- Play something
- Open the full player, tap the sleep timer icon (zZz), select any timer
- Pause the playback
- Check how many time is left in the timer
- Unpause
- ✅ The timer should restart from where it was, it should not reset
Canceling
- Play something
- Open the full player, tap the sleep timer icon (zZz), select any timer
- Open the timer sheet again and cancel the timer
- Pause and play again
- ✅ The timer should not restart
Checklist
- [x] I have considered if this change warrants user-facing release notes and have added them to
CHANGELOG.md
if necessary. - [x] I have considered adding unit tests for my changes.
- [x] I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.
@bjtitus ops, sorry! One change that I made after testing this step and adding the last two caused a regression. Thanks for the thorough testing and spotting that. I updated the code and now it should behave correctly.
Thanks, this is awesome, though please also follow up with automatic sleep timer setting during configurable hours, i.e. it should work also if you wait more than 5 mins. I see [7.64] has more sleep timer stuff, so I assume you're still working on it?
@bitmanlger this is still in the works!
Great, looking forward to it :)