거의 최종본
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:audioplayers/audioplayers.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -30,7 +29,7 @@ class _PoetScreenState extends State<PoetScreen> with WidgetsBindingObserver {
|
||||
|
||||
_backgroundImage =
|
||||
'assets/images/subsets/Sub_${(widget.selectedIndex + 1).toString().padLeft(2, '0')}.webp';
|
||||
_source = AssetSource('audio/00${(widget.selectedIndex + 1).toString()}.wav');
|
||||
_source = AssetSource('audio/${(widget.selectedIndex + 1).toString()}.mp3');
|
||||
|
||||
_audioPlayer.onPlayerStateChanged.listen((state) {
|
||||
if (mounted) {
|
||||
@@ -67,7 +66,7 @@ class _PoetScreenState extends State<PoetScreen> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
void _setSystemUIOverlayStyle() {
|
||||
if (Platform.isAndroid) {
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
|
||||
}
|
||||
}
|
||||
@@ -82,6 +81,7 @@ class _PoetScreenState extends State<PoetScreen> with WidgetsBindingObserver {
|
||||
Future<void> _setAudio() async {
|
||||
try {
|
||||
await _audioPlayer.setSource(_source);
|
||||
_audioPlayer.play(_source);
|
||||
} catch (e) {
|
||||
// Handle error, e.g., show a snackbar
|
||||
print("Error setting audio source: $e");
|
||||
@@ -91,9 +91,9 @@ class _PoetScreenState extends State<PoetScreen> with WidgetsBindingObserver {
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
if (Platform.isAndroid) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
}
|
||||
// if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
// SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
// }
|
||||
_audioPlayer.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -121,21 +121,23 @@ class _PoetScreenState extends State<PoetScreen> with WidgetsBindingObserver {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// 상단 바 (뒤로가기, 제목, 새로고침)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildCircularImageButton('assets/images/ui/UI_Back.webp', () {
|
||||
// 이 버튼을 누르면 이전 화면으로 돌아갑니다.
|
||||
Navigator.pop(context);
|
||||
}, size: 50, imageSize: 25),
|
||||
_buildCircularImageButton('assets/images/ui/UI_Replay.webp', () {
|
||||
// Refresh action here
|
||||
}, size: 50, imageSize: 25),
|
||||
],
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 50.0,left: 25),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildCircularImageButton('assets/images/ui/UI_Back.webp', () {
|
||||
// 이 버튼을 누르면 이전 화면으로 돌아갑니다.
|
||||
Navigator.pop(context);
|
||||
}, size: 90, imageSize: 90),
|
||||
// _buildCircularImageButton('assets/images/ui/UI_Replay.webp', () {
|
||||
// // Refresh action here
|
||||
// }, size: 100, imageSize: 100),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
// 하단 음악 제어
|
||||
_buildMusicControls(),
|
||||
],
|
||||
),
|
||||
@@ -177,15 +179,16 @@ class _PoetScreenState extends State<PoetScreen> with WidgetsBindingObserver {
|
||||
final newPosition = _position - const Duration(seconds: 5);
|
||||
_audioPlayer.seek(newPosition > Duration.zero ? newPosition : Duration.zero);
|
||||
}),
|
||||
const SizedBox(width: 16),
|
||||
const SizedBox(width: 100),
|
||||
_buildPlayPauseButton(),
|
||||
const SizedBox(width: 16),
|
||||
const SizedBox(width: 100),
|
||||
_buildCircularImageButton('assets/images/ui/UI_5plus.webp', () {
|
||||
final newPosition = _position + const Duration(seconds: 5);
|
||||
_audioPlayer.seek(newPosition < _duration ? newPosition : _duration);
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -204,37 +207,33 @@ class _PoetScreenState extends State<PoetScreen> with WidgetsBindingObserver {
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF07B41),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.white, width: 2),
|
||||
),
|
||||
width: 150,
|
||||
height: 150,
|
||||
|
||||
child: Center(
|
||||
child: _isPlaying
|
||||
? const Icon(Icons.pause, color: Colors.white, size: 50)
|
||||
? Image.asset(
|
||||
'assets/images/ui/UI_Pause.webp',
|
||||
width: 191,
|
||||
height: 190,
|
||||
)
|
||||
: Image.asset(
|
||||
'assets/images/ui/UI_Play.webp',
|
||||
width: 50,
|
||||
height: 50,
|
||||
width: 191,
|
||||
height: 190,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCircularImageButton(String imagePath, VoidCallback onPressed, {double size = 80, double imageSize = 50}) {
|
||||
Widget _buildCircularImageButton(String imagePath, VoidCallback onPressed, {double size = 100, double imageSize = 100}) {
|
||||
return GestureDetector(
|
||||
onTap: onPressed,
|
||||
child: Container(
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF07B41),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.white, width: 2),
|
||||
),
|
||||
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
imagePath,
|
||||
@@ -258,5 +257,5 @@ class _PoetScreenState extends State<PoetScreen> with WidgetsBindingObserver {
|
||||
].join(':');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user