Lua script to display the current playing index or video name from the video playlist (VLC Video source or any)

Sanjeewa

New Member
Hi, I just need some script to get the currently playing video, display it, and save it to the file. I can modify the lua script, but I need some help to getting the index or video name of the currently playing video from the playlist that I use as a source. ex- VLC Video source..etc
Please give your ideas for this. I'm struggling with this.
 

Keith Schneider

New Member
Try something like this, it shows the getting of a setting value in a source and also setting a value. Its a general purpose oriented function.

Example usage of the function (specifically for the VLC player filename) follows below. I do not really use print for debugging. I actually use a function. I just changed the function to print for this reply/example.

changeSourceSetting( sourceName , "local_file" , aFileSpecString , "string" )

Lua:
function changeSourceSetting( source, settingKey , settingValue , settingType )
    local wasValue = ""
    if settingType == "string" or settingType == "int" or settingType == "bool" or settingType == "double" then
        local srcObj = obs.obs_get_source_by_name( source )                        -- getObj srcObj
        if srcObj ~= nil then
            local curSettings = obs.obs_source_get_settings( srcObj )            -- getObj curSettings
            if settingType == "string" then wasValue = obs.obs_data_get_string( curSettings , settingKey ) end
            if settingType == "int"    then wasValue = obs.obs_data_get_int   ( curSettings , settingKey ) end
            if settingType == "bool"   then wasValue = obs.obs_data_get_bool  ( curSettings , settingKey ) end
            if settingType == "double" then wasValue = obs.obs_data_get_double( curSettings , settingKey ) end
            -- update the settings via given key/value
            if settingType == "string" then               obs.obs_data_set_string( curSettings , settingKey, settingValue ) end
            if settingType == "int"    then               obs.obs_data_set_int   ( curSettings , settingKey, settingValue ) end
            if settingType == "bool"   then               obs.obs_data_set_bool  ( curSettings , settingKey, settingValue ) end
            if settingType == "double" then               obs.obs_data_set_double( curSettings , settingKey, settingValue ) end
            obs.obs_source_update(srcObj, curSettings)
            obs.obs_data_release(curSettings)                                    -- release curSettings
            obs.obs_source_release(srcObj)                                        -- release srcObj
        else
            print("changeSourceSetting - Requested SourceObj Not Found for: "..source )
        end
    else
        print( "changeSourceSetting - Requested settingType invalid: "..settingType )
    end
    return wasValue
end
 

iszotic

New Member
Hi, Tuna does get only the title of the current media with VLC and saves it to a text file, but I don't see where to get the current index playing on a VLC source with a script using only functions from obs, the settings of this source are these printing them in JSON form:
{'playlist': [], 'subtitle_enable': True, 'subtitle': 1}
And the functions related to media obs.source_media_* are not useful for this.
In the meantime, I have to put the basename (last part of the path) on the title of the media and load the text file with the title of the current media from Tuna and then check for the path of each entry in the playlist to get the current index...
 
Top