Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ Add a method to pause all players at once #372

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

himanshuGandhiSimform
Copy link
Collaborator

Fixed 325

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -140,15 +140,16 @@ class AudioPlayer(
}


fun pause(result: MethodChannel.Result) {
fun pause(result: MethodChannel.Result, isPauseAllPlayer: Boolean = false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this boolean?

@@ -91,10 +91,12 @@ class AudioPlayer: NSObject, AVAudioPlayerDelegate {
}


func pausePlayer(result: @escaping FlutterResult) {
func pausePlayer(result: @escaping FlutterResult, isPauseAllPlayer: Bool = false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^

ios/Classes/SwiftAudioWaveformsPlugin.swift Outdated Show resolved Hide resolved
lib/src/controllers/player_controller.dart Outdated Show resolved Hide resolved
@himanshuGandhiSimform himanshuGandhiSimform force-pushed the feature/325/pause_all_players branch from 26deec9 to ef20485 Compare December 9, 2024 07:15
@jay-simformsolutions jay-simformsolutions force-pushed the feature/325/pause_all_players branch from ef20485 to ba326d8 Compare January 7, 2025 10:57
```dart
playerController.pauseAllPlayers();
```
There could be any number of players but you can just call this function from any **one** player and it will pause all the players.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just write, this function works similar to stopAllPlayer.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this changes

Comment on lines +143 to +144
stopListening()
player?.pause()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add try catch

@@ -129,26 +129,19 @@ class AudioPlayer(
}
}

fun stop(result: MethodChannel.Result) {
fun stop() {
stopListening()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add try catch

.forEach((playKey, controller) {
controller._setPlayerState(PlayerState.stopped);
});
}
PlatformStreams.instance.playerControllerFactory.clear();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont need clear since we aren't releasing player.

pubspec.yaml Outdated
@@ -1,6 +1,6 @@
name: audio_waveforms
description: A Flutter package that allow you to generate waveform while recording audio or from audio file.
version: 1.2.0
version: 1.2.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update to 1.3.0

@jay-simformsolutions jay-simformsolutions force-pushed the feature/325/pause_all_players branch from ba326d8 to e9850d7 Compare January 8, 2025 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pauseAllPlayers() or in PlayerController add option on play - pause other controllers
2 participants