Skip to content

Commit

Permalink
Functional
Browse files Browse the repository at this point in the history
  • Loading branch information
WhatDamon committed Feb 9, 2024
1 parent 617904d commit c50b2f5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
with:
nuitka-version: main
script-name: main.py
onefile: true
standalone: true
disable-console: true

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/buildwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
with:
nuitka-version: main
script-name: main.py
onefile: true
standalone: true
disable-console: true
windows-icon-from-ico: ./asset/spicon.ico
Expand All @@ -50,4 +51,4 @@ jobs:
with:
name: ${{ runner.os }} Build
path: |
build/*
build/*.exe
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ___注:区分的原因是 `Windows-Toasts` 库只能在 Windows 下生效!___
- [x] GitHub Actions 自动测试编译工作流 (使用 __Nuitka__ 实现, 详见[本项目 Actions](https://github.com/WhatDamon/Simplay-Player/actions))
- [x] 多语言支持 (基本, 目前只有美式英语 `en_US` 和简体中文 `zh_CN`, 若要贡献翻译请到 `i18n` 目录)
- [x] 日志输出 (注: 会产生大量日志信息)
- [ ] 循环播放 (遇到技术性难题, 暂时注释了 `enableOrDisable` 函数 (函数临时被注释), 预留了占位按钮 `playInLoop_btn` (组件已隐藏) 和状态变量 `loopOpen`)
- [x] 循环播放
- [ ] 设置 (目前已有占位按钮 `settings_btn`, 并隐藏)
- [ ] 歌词显示与滚动 (已预留了歌词路径变量 `lyricFile` 和读取函数 `lyricExistAndRead`(函数临时被注释))
- [ ] 歌单 (施工中)
Expand Down
55 changes: 30 additions & 25 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
audioInfo = None
audioTitleText = None
audioArtistText = None
audioAlbumText = None
currentOS = None

logging.info("Variable initialization complete")
Expand Down Expand Up @@ -140,24 +141,32 @@ def audioInfoUpdate():
logging.info("Placeholder cover loaded")
audioCover.update()
logging.info("audioCover updated")
global audioTitleText, audioArtistText
global audioTitleText, audioArtistText, audioAlbumText
if audioTag.title != None:
audioTitleText = audioTag.title
logging.info("Set audio title")
logging.info("Set audio title: " + audioTitleText)
else:
audioTitleText = lang.mainMenu["unknownMusic"]
logging.info("Unknown audio title")
if audioTag.artist != None:
audioArtistText = audioTag.artist
logging.info("Set audio artist")
logging.info("Set audio artist: " + audioArtistText)
else:
audioArtistText = lang.mainMenu["unknownArtist"]
logging.info("Unknown audio artist")
if audioTag.album != None:
audioAlbumText = audioTag.album
logging.info("Find audio album and loaded: " + audioAlbumText)
global audioInfo
audioInfo = "Album: " + str(audioTag.album) + "\nAlbumist: " + str(audioTag.albumartist) + "\nArtist: " + str(audioTag.artist) + "\nAudio Offset: " + str(audioTag.audio_offset) + "\nBitrate: " + str(audioTag.bitrate) + "\nBitdepth: " + str(audioTag.bitdepth) + "\nChannels: " + str(audioTag.channels) + "\nComment: " + str(audioTag.comment)+ "\nComposer: " + str(audioTag.composer) + "\nDisc: " + str(audioTag.disc) + "\nDisc Total: " + str(audioTag.disc_total) + "\nDuration: " + str(audioTag.duration) + "\nFilesize: " + str(audioTag.filesize) + "\nGenre: " + str(audioTag.genre) + "\nSamplerate: " + str(audioTag.samplerate) + "\nTitle: " + str(audioTag.title) + "\nTrack: " + str(audioTag.track) + "\nTrack Total: " + str(audioTag.track_total) + "\nYear: " + str(audioTag.year)
logging.info("Set audio info")
audioTitle.value = audioTitleText
audioArtist.value = audioArtistText
if audioAlbumText == None:
audioArtistAndAlbum.value = audioArtistText
logging.info("No album text loaded")
else:
audioArtistAndAlbum.value = audioArtistText + " · " + audioAlbumText
logging.info("Album text loaded")
logging.info("Load audio info to interface")
page.update()
logging.info("Page updated")
Expand Down Expand Up @@ -298,28 +307,25 @@ def rateChangeTo20(e):
def autoKeepAudioProgress(e):
if progressChanging == False:
audioProgressBar.value = playAudio.get_current_position() / playAudio.get_duration() * 1000
global loopOpen
if playAudio.get_current_position() == playAudio.get_duration() and loopOpen == True:
playAudio.seek(0)
currentLength = secondConvert(playAudio.get_current_position() // 1000)
totalLength = secondConvert(playAudio.get_duration() // 1000)
audioProgressStatus.value = currentLength + "/" + totalLength
page.update()

"""
def enableOrDisableLoop(e):
global loopOpen
if loopOpen == False:
loopOpen = True
page.snack_bar = ft.SnackBar(ft.Text(value = lang.mainMenu["enableLoop"]))
page.snack_bar.open = True
playAudio.release_mode = ft.audio.ReleaseMode.LOOP
playInLoop_btn.icon = ft.icons.STOP_CIRCLE_OUTLINED
logging.info("Loop enabled")
elif loopOpen == True:
loopOpen = False
print(playAudio.release_mode)
# playAudio.release_mode = ReleaseMode.LOOP
playAudio.release_mode = ft.audio.ReleaseMode.RELEASE
playInLoop_btn.icon = ft.icons.LOOP_OUTLINED
logging.info("Loop disabled")
page.update()
logging.info("Page updated")
"""

def autoStopKeepAudioProgress(e):
global progressChanging
Expand Down Expand Up @@ -575,9 +581,9 @@ def balanceMiddle(e):

audioCover = ft.Image(src = './asset/track.png', width = 128, height = 128, border_radius = 5)
audioTitle = ft.Text(audioTitleText, weight = ft.FontWeight.BOLD, size = 25, overflow = ft.TextOverflow.ELLIPSIS)
audioArtist = ft.Text(audioArtistText, size = 18, opacity = 90)
audioArtistAndAlbum = ft.Text(audioArtistText, size = 18, opacity = 90)
audioProgressStatus = ft.Text("00:00/00:00", size = 15, opacity = 90)
audioDetail = ft.Column(controls = [audioTitle, audioArtist, audioProgressStatus])
audioDetail = ft.Column(controls = [audioTitle, audioArtistAndAlbum, audioProgressStatus])
audioBasicInfo = ft.Row(controls = [audioCover, audioDetail])

audioProgressBar = ft.Slider(min = 0, max = 1000, tooltip = lang.tooltips["audioPosition"], on_change_start = autoStopKeepAudioProgress, on_change_end = progressCtrl)
Expand All @@ -589,14 +595,6 @@ def balanceMiddle(e):
on_click = playOrPauseMusic
)

playInLoop = ft.IconButton(
icon = ft.icons.LOOP_OUTLINED,
tooltip = lang.tooltips["playInLoop"],
icon_size = 20,
visible = False
# on_click = enableOrDisableLoop
)

volume_btn = ft.IconButton(
icon = ft.icons.VOLUME_UP_OUTLINED,
tooltip = lang.tooltips["volume"],
Expand All @@ -612,6 +610,13 @@ def balanceMiddle(e):
height = 46,
width = 200
)

playInLoop_btn = ft.IconButton(
icon = ft.icons.LOOP_OUTLINED,
tooltip = lang.tooltips["playInLoop"],
icon_size = 20,
on_click = enableOrDisableLoop
)

audioList_btn = ft.IconButton(
icon = ft.icons.LIBRARY_MUSIC_OUTLINED,
Expand Down Expand Up @@ -663,8 +668,8 @@ def balanceMiddle(e):

lyric_text = ft.Text(size = 20)

playbackCtrl_row = ft.Row(controls = [playPause_btn, playInLoop, volume_btn, volume_panel])
moreBtns_row = ft.Row(controls = [audioList_btn, audioInfo_btn, settings_btn])
playbackCtrl_row = ft.Row(controls = [playPause_btn, volume_btn, volume_panel])
moreBtns_row = ft.Row(controls = [playInLoop_btn, audioList_btn, audioInfo_btn, settings_btn])
btns_row = ft.Row(controls = [playbackCtrl_row, moreBtns_row], alignment = ft.MainAxisAlignment.SPACE_BETWEEN)

page.overlay.append(audioList_menu)
Expand Down

0 comments on commit c50b2f5

Please sign in to comment.