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

Request to Replace the steps Section 9 AudioPlayer #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 28 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,48 +197,43 @@
##### [Go back to Index](#index)

- Getting a lengthy error when trying to use **`audioplayers` plugin**?

- All you need to do is open **`android > build.gradle` (Project Level `gradle` file)**

- Inside **`buildscript {}`**, you'll find **`ext.kotlin_version` (Line 2 in file)**

- Replace whatever version it is with [**Latest Stable Kotlin Version**](https://kotlinlang.org/docs/releases.html#release-details)

- As of **July 23, 2021** it is, **`ext.kotlin_version = '1.5.21'`**

- Now, **re-install** the app. If it's already running, press **Stop** then press **Run (Play)** again.

- **`FlatButton`** is **`deprecated`**, so use **`TextButton`** instead.
- first you need to play the sound from "asset/note1.wav"

- By the end, the implementation of your **`TextButton`** should look like this:

```dart
- Then you can copy paste this code :

```dart
import 'package:flutter/material.dart';
import 'package:audioplayers/audioplayers.dart';

void main() => runApp(XylophoneApp());

class XylophoneApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Expanded(
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(color),
final player = AudioPlayer();

return MaterialApp(
home: Scaffold(
body: SafeArea(
child: Center(
child: TextButton(
onPressed: () async {
await player.play(AssetSource('note1.wav'));
},
child: Text("Click me"),
),
),
),
onPressed: () {
playSound(soundNumber);
},
),
);
}
```

- **`AudioCache`** is **`deprecated`**, so use **`AudioPlayer`** instead.
- By the end, your solution to playing the audio should look like this:
```dart
void playSound(int soundNumber) {
final player = AudioPlayer();
player.setSource(AssetSource('note$soundNumber.wav'));
}
```
}
```
- after that start your programe , it should work

- **`AudioCache`** is **`deprecated`**, so use **`AudioPlayer`** instead.

- An example of a working project as of 16/07/2022 has been linked below:
- [Link to repository](https://github.com/vpatel-dev/xylophone-flutter)

## Section 10 : Quizzler App (Lesson 94)

Expand Down