10-20-2022, 02:37 AM
Here's some code that is a little more cleaned up and sizes the picture down a bit:
Code: (Select All)
Option Explicit
$NoPrefix
$Console
Dim As String file: file = "07 - Project 86 - Team Black.flac"
Dim As Long hfile: hfile = FreeFile
Open "B", hfile, file
Dim As String rawdata: rawdata = Space$(LOF(hfile))
Get hfile, , rawdata
Close
Dim As String SOI: SOI = Chr$(&HFF) + Chr$(&HD8)
Dim As String EOI: EOI = Chr$(&HFF) + Chr$(&HD9)
Dim As String lyrics: lyrics = Mid$(rawdata, InStr(rawdata, "LYRICS=") + Len("LYRICS=")): lyrics = Mid$(lyrics, 1, InStr(lyrics, Chr$(0)) - 2)
Dim As Long tracknumber: Dim As String track: track = Mid$(rawdata, InStr(rawdata, "TRACKNUMBER=") + Len("TRACKNUMBER=")): track = Mid$(track, 1, InStr(track, Chr$(0))): tracknumber = Val(track)
Dim As String songtitle: songtitle = Mid$(rawdata, InStr(rawdata, "TITLE=") + Len("TITLE=")): songtitle = Mid$(songtitle, 1, InStr(songtitle, Chr$(0)) - 2)
Dim As String albumtitle: albumtitle = Mid$(rawdata, InStr(rawdata, "ALBUM=") + Len("ALBUM=")): albumtitle = Mid$(albumtitle, 1, InStr(albumtitle, Chr$(0)) - 2)
Dim As String artist: artist = Mid$(rawdata, InStr(rawdata, "ARTIST=") + Len("ARTIST=")): artist = Mid$(artist, 1, InStr(artist, Chr$(0)) - 2)
Dim As String albumdate: albumdate = Mid$(rawdata, InStr(rawdata, "DATE=") + Len("DATE=")): albumdate = Mid$(albumdate, 1, InStr(albumdate, Chr$(6)) - 1)
Dim As String image: image = Mid$(rawdata, InStr(rawdata, SOI)): image = Mid$(image, 1, InStr(image, EOI) + Len(EOI))
If Len(image) > 0 Then
Dim As Long hpic: hpic = FreeFile
If FileExists("cover.jpg") Then Kill "cover.jpg"
Open "B", hpic, "cover.jpg"
Put hpic, , image
Close
Dim As Long i: i = LoadImage("cover.jpg", 32)
If i < -1 Then Screen NewImage(640, 640, 32) 'for testing
Dest 0
Source i
rawdata = ""
Echo lyrics
Title artist + " - " + songtitle
ConsoleTitle Title$ + " lyrics"
Dim As Long snd: snd = SndOpen(file, "stream")
If snd Then SndPlay snd
Do
Cls
PutImage
Print "Artist:", artist
Print "Album :", albumtitle
Print "Track :", tracknumber
Print "Title :", songtitle
Print "Date :", albumdate
Print SndGetPos(snd)
Display
Limit 60
Loop Until InKey$ <> ""
End If
Tread on those who tread on you