I'm going the database way now.
But guesse what, I get stuck.
I'm trying to make a package.
The installation should execute some code. And that code should create a table called "CurrentPlay". It should also create 5 rows. With 2 colums ID (1,2,3,4,5) and SongID (At creation all 0 (null)). I use the following code and I suppose this works
good.
Install.ini
Code: Select all
[Header]
ID=CurrentPlay110107
Title=Currently Playing
Description=Puts the currently playing song in a table
VersionMajor=0
VersionMinor=0
VersionRelease=0
VersionBuild=0
Type=script
[Copy]
Src=CPUpdate.vbs
Tgt={app}\Scripts\auto\CPUpdate.vbs
[Execute]
File=CPCreate.vbs
CPCreate.vbs
Code: Select all
Dim SelectMethod
Dim SQLString
Dim objSongStringiterator
Dim Create
SelectMethod = 2
SQLString = "CREATE TABLE CurrentPlay(ID INTEGER PRIMARY KEY ASC, SongID)"
set objSongStringiterator = SDB.Database.OpenSQL(SQLString)
SQLString = "INSERT INTO CurrentPlay values(1,0)"
set Create = SDB.Database.OpenSQL(SQLString)
SQLString = "INSERT INTO CurrentPlay values(2,0)"
set Create = SDB.Database.OpenSQL(SQLString)
SQLString = "INSERT INTO CurrentPlay values(3,0)"
set Create = SDB.Database.OpenSQL(SQLString)
SQLString = "INSERT INTO CurrentPlay values(4,0)"
set Create = SDB.Database.OpenSQL(SQLString)
SQLString = "INSERT INTO CurrentPlay values(5,0)"
set Create = SDB.Database.OpenSQL(SQLString)
The Unistallation looks like this (I have no idea if it woks):
Unistall.ini
Code: Select all
[Delete]
File={app}\Scripts\auto\CPUpdate.vbs
[Execute]
File=CPDelete.vbs
CPDelete.vbs
Code: Select all
Dim SelectMethod
Dim SQLString
Dim objSongStringiterator
Dim Create
SelectMethod = 2
SQLString = "DROP TABLE CurrentPlay"
set objSongStringiterator = SDB.Database.OpenSQL(SQLString)
But now comes the problem. Made a auto-script to update the SongID of a specified ID.
But nothing seems to happen.
I used and changed the script from here:
http://www.mediamonkey.com/forum/viewto ... f=2&t=5404 (a post from
Steegy)
Now the code looks like this:
CPUpdate.vbs
Code: Select all
Option Explicit
Dim Update
Dim SelectMethod
Dim Row
Row = 1
SelectMethod = 2
Sub OnStartUp
Script.RegisterEvent SDB, "OnPlay", "WriteSignatureFile"
Script.RegisterEvent SDB, "OnStop", "DeleteSignatureFile"
Script.RegisterEvent SDB, "OnShutDown", "DeleteSignatureFile"
End Sub
Sub WriteSignatureFile
On Error Resume Next
Dim oTrack
Set oTrack = SDB.Player.CurrentSong
SQLString = "UPDATE CurrentPlay set SongID='" & oTrack.SongID & "' WHERE ID='" & Row & "'"
set Update = SDB.Database.OpenSQL(SQLString)
End Sub
Sub DeleteSignatureFile
On Error Resume Next
Dim oTrack
Set oTrack = SDB.Player.CurrentSong
SQLString = "UPDATE CurrentPlay set SongID='999' WHERE ID=" & Row & "'"
set Update = SDB.Database.OpenSQL(SQLString)
End Sub
Could anyway find any problom in the code and/or an solution to solve it. Or got an other idea or work around?
I'm going the database way now.
But guesse what, I get stuck.
I'm trying to make a package.
The installation should execute some code. And that code should create a table called "CurrentPlay". It should also create 5 rows. With 2 colums ID (1,2,3,4,5) and SongID (At creation all 0 (null)). I use the following code and I suppose this works [b]good[/b].
Install.ini
[code]
[Header]
ID=CurrentPlay110107
Title=Currently Playing
Description=Puts the currently playing song in a table
VersionMajor=0
VersionMinor=0
VersionRelease=0
VersionBuild=0
Type=script
[Copy]
Src=CPUpdate.vbs
Tgt={app}\Scripts\auto\CPUpdate.vbs
[Execute]
File=CPCreate.vbs
[/code]
CPCreate.vbs
[code]Dim SelectMethod
Dim SQLString
Dim objSongStringiterator
Dim Create
SelectMethod = 2
SQLString = "CREATE TABLE CurrentPlay(ID INTEGER PRIMARY KEY ASC, SongID)"
set objSongStringiterator = SDB.Database.OpenSQL(SQLString)
SQLString = "INSERT INTO CurrentPlay values(1,0)"
set Create = SDB.Database.OpenSQL(SQLString)
SQLString = "INSERT INTO CurrentPlay values(2,0)"
set Create = SDB.Database.OpenSQL(SQLString)
SQLString = "INSERT INTO CurrentPlay values(3,0)"
set Create = SDB.Database.OpenSQL(SQLString)
SQLString = "INSERT INTO CurrentPlay values(4,0)"
set Create = SDB.Database.OpenSQL(SQLString)
SQLString = "INSERT INTO CurrentPlay values(5,0)"
set Create = SDB.Database.OpenSQL(SQLString)[/code]
The Unistallation looks like this (I have no idea if it woks):
Unistall.ini
[code][Delete]
File={app}\Scripts\auto\CPUpdate.vbs
[Execute]
File=CPDelete.vbs[/code]
CPDelete.vbs
[code]Dim SelectMethod
Dim SQLString
Dim objSongStringiterator
Dim Create
SelectMethod = 2
SQLString = "DROP TABLE CurrentPlay"
set objSongStringiterator = SDB.Database.OpenSQL(SQLString)[/code]
But now comes the problem. Made a auto-script to update the SongID of a specified ID.
But nothing seems to happen.
I used and changed the script from here: http://www.mediamonkey.com/forum/viewtopic.php?f=2&t=5404 (a post from [b]Steegy[/b])
Now the code looks like this:
CPUpdate.vbs
[code]Option Explicit
Dim Update
Dim SelectMethod
Dim Row
Row = 1
SelectMethod = 2
Sub OnStartUp
Script.RegisterEvent SDB, "OnPlay", "WriteSignatureFile"
Script.RegisterEvent SDB, "OnStop", "DeleteSignatureFile"
Script.RegisterEvent SDB, "OnShutDown", "DeleteSignatureFile"
End Sub
Sub WriteSignatureFile
On Error Resume Next
Dim oTrack
Set oTrack = SDB.Player.CurrentSong
SQLString = "UPDATE CurrentPlay set SongID='" & oTrack.SongID & "' WHERE ID='" & Row & "'"
set Update = SDB.Database.OpenSQL(SQLString)
End Sub
Sub DeleteSignatureFile
On Error Resume Next
Dim oTrack
Set oTrack = SDB.Player.CurrentSong
SQLString = "UPDATE CurrentPlay set SongID='999' WHERE ID=" & Row & "'"
set Update = SDB.Database.OpenSQL(SQLString)
End Sub[/code]
Could anyway find any problom in the code and/or an solution to solve it. Or got an other idea or work around?