View Issue Details

IDProjectCategoryView StatusLast Update
0009135MMW v4Framework: Scripts/Extensionspublic2012-02-15 07:48
Reporterzvezdan Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Summary0009135: All SDBMedia properties are read-only, even when wiki says that some could be set
DescriptionNone Media property could be set, neither Label nor Serial Number. Here is the test code:
Option Explicit

Sub OnStartUp()
    Dim oMenuItem

    SDB.UI.AddMenuItemSep SDB.UI.Menu_Edit, -3, 0

    Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0)
    oMenuItem.Caption = "Modify first track from E: in Library"
    oMenuItem.OnClickFunc = "Test1"
    oMenuItem.UseScript = Script.ScriptPath

    Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0)
    oMenuItem.Caption = "Add new virtual track to Library"
    oMenuItem.OnClickFunc = "Test2"
    oMenuItem.UseScript = Script.ScriptPath
End Sub

Sub Test1(oMenuItem)
    Dim sQuery
    Dim oSongIter
    Dim oSongData
    Dim oDbIter

    sQuery = "IDMedia = (SELECT IDMedia FROM Medias WHERE DriveLetter = 4)"
    Set oSongIter = SDB.Database.QuerySongs(sQuery)
    If Not oSongIter.EOF Then
        Set oSongData = oSongIter.Item
        oSongData.Media.MediaLabel = "Zvezdan"
        oSongData.Media.SerialNumber = &H12345678
        oSongData.UpdateDB
        Set oSongIter = Nothing

        sQuery = "SELECT SerialNumber, Label FROM Medias WHERE DriveLetter = 4"
        Set oDbIter = SDB.Database.OpenSQL(sQuery)
        If Not oDbIter.EOF Then
            SDB.MessageBox "SerialNumber: " & oDbIter.ValueByIndex(0) & vbCr _
                    & "Label: " & oDbIter.ValueByIndex(1), _
                    mtInformation, Array(mbOK)
        End If
    Else
        SDB.MessageBox "There is no any track on E: drive.", _
                mtInformation, Array(mbOK)
    End If
End Sub

Sub Test2(oMenuItem)
    Dim oSongData
    Dim sQuery
    Dim oDbIter

    Set oSongData = SDB.NewSongData
    oSongData.Path = "E:\"
    oSongData.Title = "MyLoc"
    oSongData.Media.MediaLabel = "Zvezdan"
    oSongData.Media.SerialNumber = &H12345678
    oSongData.UpdateDB

    sQuery = "SELECT SerialNumber, Label FROM Medias WHERE DriveLetter = 4"
    Set oDbIter = SDB.Database.OpenSQL(sQuery)
    If Not oDbIter.EOF Then
        SDB.MessageBox "SerialNumber: " & oDbIter.ValueByIndex(0) & vbCr _
                & "Label: " & oDbIter.ValueByIndex(1), _
                mtInformation, Array(mbOK)
    End If

    sQuery = "DELETE FROM Songs WHERE SongTitle = 'MyLoc' AND SongPath = ':\'"
    SDB.DataBase.ExecSQL sQuery
End Sub
Steps To ReproduceWith the first option you need to have E: drive, or change DriveLetter in code appropriately. The second option adds virtual track to the Library and adds E: drive to the Medias table, but not with the specified MediaLabel and SerialNumber but with the already assigned values to the drive.
TagsNo tags attached.
Fixed in build

Activities

There are no notes attached to this issue.