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

Add audio session #61

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
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
Binary file added assets/audio/blank.mp3
Binary file not shown.
7 changes: 7 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,12 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)

target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
'AUDIO_SESSION_MICROPHONE=0'
]
end
end
end
8 changes: 7 additions & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PODS:
- audio_session (0.0.1):
- Flutter
- audioplayers_darwin (0.0.1):
- Flutter
- Flutter (1.0.0)
Expand All @@ -15,6 +17,7 @@ PODS:
- Flutter

DEPENDENCIES:
- audio_session (from `.symlinks/plugins/audio_session/ios`)
- audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/ios`)
- Flutter (from `Flutter`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
Expand All @@ -26,6 +29,8 @@ SPEC REPOS:
- FMDB

EXTERNAL SOURCES:
audio_session:
:path: ".symlinks/plugins/audio_session/ios"
audioplayers_darwin:
:path: ".symlinks/plugins/audioplayers_darwin/ios"
Flutter:
Expand All @@ -38,10 +43,11 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/wakelock/ios"

SPEC CHECKSUMS:
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f

Expand Down
12 changes: 12 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:convert';

import 'package:audio_session/audio_session.dart';
import 'package:flutter/material.dart';
import 'create_workout/select_timer.dart';
import 'workout_data_type/workout_type.dart';
Expand Down Expand Up @@ -41,6 +42,17 @@ class _MyHomePageState extends State<MyHomePage> {
/// The list of workouts to be loaded with [DatabaseManager()].
late Future<List<Workout>> workouts;

@override
initState() {
super.initState();
init();
}

void init() async {
final session = await AudioSession.instance;
await session.configure(const AudioSessionConfiguration.music());
}

int calculateWorkoutTime(Workout workout) {
return (((workout.exerciseTime * workout.numExercises) +
(workout.restTime * (workout.numExercises - 1)) +
Expand Down
7 changes: 7 additions & 0 deletions lib/start_workout/workout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ class CountDownTimerState extends State<CountDownTimer>
_controllerCenter =
ConfettiController(duration: const Duration(seconds: 10));
Wakelock.enable();
init();
}

void init() async {
// final session = await AudioSession.instance;
// await session.configure(const AudioSessionConfiguration.music());
await player.play(AssetSource('audio/blank.mp3'));
}

@override
Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import FlutterMacOS
import Foundation

import audio_session
import audioplayers_darwin
import path_provider_foundation
import sqflite
import wakelock_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
Expand Down
16 changes: 16 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.11.0"
audio_session:
dependency: "direct main"
description:
name: audio_session
sha256: "8a2bc5e30520e18f3fb0e366793d78057fb64cd5287862c76af0c8771f2a52ad"
url: "https://pub.dev"
source: hosted
version: "0.1.16"
audioplayers:
dependency: "direct main"
description:
Expand Down Expand Up @@ -425,6 +433,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.7.3"
rxdart:
dependency: transitive
description:
name: rxdart
sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb"
url: "https://pub.dev"
source: hosted
version: "0.27.7"
sky_engine:
dependency: transitive
description: flutter
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies:
wakelock: ^0.6.2
flutter_launcher_icons: ^0.13.1
coverage: ^1.6.3
audio_session: ^0.1.16

flutter_launcher_icons:
android: "launcher_icon"
Expand Down
Loading