Xogy / xsound

Improved audio library for FiveM
MIT License
115 stars 82 forks source link

Max Duration and Timestamp always return 0 #40

Closed AdlanDzulkfali closed 1 year ago

AdlanDzulkfali commented 1 year ago

When I try to get the sound info. maxduration and timestamp always return 0 for youtube song. Is this expected or is it a bug? below is the data that I've captured

{"maxDuration":0,"volume":0.55,"timeStamp":0,"paused":false,"isDynamic":true,"loop":false,"distance":10,"url":"https://www.youtube.com/watch?v=nKgN0ZzJP4c","playing":true,"position":{"x":82.59248352050781,"y":-865.4900512695313,"z":134.7701416015625},"id":"test","destroyOnFinish":true}

Xogy commented 1 year ago

When I try to get the sound info. maxduration and timestamp always return 0 for youtube song. Is this expected or is it a bug? below is the data that I've captured

{"maxDuration":0,"volume":0.55,"timeStamp":0,"paused":false,"isDynamic":true,"loop":false,"distance":10,"url":"https://www.youtube.com/watch?v=nKgN0ZzJP4c","playing":true,"position":{"x":82.59248352050781,"y":-865.4900512695313,"z":134.7701416015625},"id":"test","destroyOnFinish":true}

The onPlay event has priority over timestamp you have to just wait 1ms to get the timestamp aswell. I will switch the priority event so it can be done without waiting.

CreateThread(function()
    Wait(2000)

    PlayUrlPos("test", "https://www.youtube.com/watch?v=nKgN0ZzJP4c", 0.55, GetEntityCoords(PlayerPedId()), false)

    onPlayStart("test", function()
        Wait(1)
        dump(getInfo("test"))
    end)
end)
Xogy commented 1 year ago

https://github.com/Xogy/xsound/commit/cd313f920a841241c030b0171c59400f9bac3c40