Skip to content

Commit

Permalink
audio
Browse files Browse the repository at this point in the history
  • Loading branch information
wvzv committed Dec 4, 2022
1 parent 317695d commit 888e98f
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 5 deletions.
Binary file added assets/audio/Tintin.mp3
Binary file not shown.
Binary file removed assets/audio/backgroundAudio.mp3
Binary file not shown.
5 changes: 5 additions & 0 deletions lib/Global/constant.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// ignore_for_file: prefer_const_constructors

import 'package:audioplayers/audioplayers.dart';

/// SCORE Variables calculated in function [startGame] in [GamePage]
int score = 0;
int topScore = 0;
Expand Down Expand Up @@ -30,3 +32,6 @@ double barrierMovement = 0.05;
/// Screen Boundary
double screenEnd = -1.9;
double screenStart = 3.5;
/// audio
final player = AudioPlayer();
bool play = true;
12 changes: 12 additions & 0 deletions lib/Global/functions.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ignore_for_file: prefer_const_constructors
import 'package:audioplayers/audioplayers.dart';
import 'package:flappy_bird/Resources/strings.dart';
import 'package:flutter/material.dart';
import '../Database/database.dart';
Expand Down Expand Up @@ -72,6 +73,17 @@ void init() {
}else{
write("level", barrierMovement);
}
if(read("audio") != null){
play = read("audio");
}else{
write("audio", play);
}
if(play){
player.play(AssetSource("audio/Tintin.mp3"));
}else{
player.stop();
}
player.setReleaseMode(ReleaseMode.loop);
}

void navigate(context,navigate){
Expand Down
2 changes: 1 addition & 1 deletion lib/Layouts/Pages/page_settings.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ignore_for_file: prefer_const_constructors, sized_box_for_whitespace
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, avoid_unnecessary_containers
// ignore_for_file: prefer_const_literals_to_create_immutables, avoid_unnecessary_containers
import 'package:flappy_bird/Layouts/Pages/page_start_screen.dart';
import 'package:flappy_bird/Layouts/Widgets/widget_bird_settings.dart';
import 'package:flappy_bird/Layouts/Widgets/widget_difficulty_settings.dart';
Expand Down
2 changes: 2 additions & 0 deletions lib/Layouts/Widgets/widget_music_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class _MusicSettingsState extends State<MusicSettings> {
children: [
GestureDetector(onTap: () async {
write("audio", true);
await player.resume();
},
child: Icon(Icons.music_note_rounded,size: 40,)),
GestureDetector(onTap: () async {
write("audio", false);
await player.pause();
},
child: Icon(Icons.music_off_rounded,size: 40)),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/Resources/strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class Str{
" controls a bird, attempting to fly between "
" columns of green pipes without hitting them";

static String image = "";
static String image = "0";
static String bird = "assets/pics/bird.png";
}
56 changes: 56 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,55 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
audioplayers:
dependency: "direct main"
description:
name: audioplayers
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
audioplayers_android:
dependency: transitive
description:
name: audioplayers_android
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
audioplayers_darwin:
dependency: transitive
description:
name: audioplayers_darwin
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
audioplayers_linux:
dependency: transitive
description:
name: audioplayers_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
audioplayers_platform_interface:
dependency: transitive
description:
name: audioplayers_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
audioplayers_web:
dependency: transitive
description:
name: audioplayers_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
audioplayers_windows:
dependency: transitive
description:
name: audioplayers_windows
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -714,6 +763,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.7"
vector_math:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies:
path_provider: ^2.0.3
smooth_star_rating: ^1.0.4+2
rating_dialog:
audioplayers:
smooth_star_rating_null_safety: ^1.0.4+2
share_plus: ^4.0.10+1
share: ^2.0.4
Expand Down
4 changes: 1 addition & 3 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

// ignore_for_file: prefer_const_constructors

import 'package:flappy_bird/Layouts/Pages/page_game.dart';
import 'package:flappy_bird/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:flappy_bird/core/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
Expand Down

0 comments on commit 888e98f

Please sign in to comment.