Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watching a video that is over an hour long causes nil pointers related to the progress bar #13

Open
TheKamboy opened this issue Jan 6, 2025 · 3 comments

Comments

@TheKamboy
Copy link

The title explains it.

Notification Message: /usr/share/calla/desktop/theme/control/media.lua:139: attempt to preform arithmetic on a nil value

@TheKamboy
Copy link
Author

TheKamboy commented Jan 7, 2025

ok i made a fix, sadly the progress bar seems to not work with over an hour long content (still works with shorter content)
file: calla/desktop/theme/control/media.lua

awesome.connect_signal("signal::playerctl", function(title, album, artist, cover, elapsed, total, status)
	media:get_children_by_id("title")[1].text = title
	media:get_children_by_id("artist")[1].text = artist

	local coverart = cover
	if cover == "None" then
		coverart = beautiful.calla
	end
	media:get_children_by_id("cover")[1].image = coverart

	-- if total ~= "" then
	-- 	media:get_children_by_id("elapsed")[1].text = elapsed
	-- 	media:get_children_by_id("total")[1].text = total
	-- 	local elapsedseconds = tonumber(elapsed:match("(.*):"))*60 + tonumber(elapsed:match(":(.*)"))
	-- 	local totalseconds = tonumber(total:match("(.*):"))*60 + tonumber(total:match(":(.*)"))
	-- 	media:get_children_by_id("progress")[1].value = elapsedseconds
	-- 	media:get_children_by_id("progress")[1].max_value = totalseconds
	-- end

	if total ~= "" then
		media:get_children_by_id("elapsed")[1].text = elapsed
		media:get_children_by_id("total")[1].text = total

		if string.match(total, "(%d+):(%d+):(%d+)") == nil then
			local elapsedseconds = tonumber(elapsed:match("(.*):")) * 60 + tonumber(elapsed:match(":(.*)"))
			local totalseconds = tonumber(total:match("(.*):")) * 60 + tonumber(total:match(":(.*)"))
			media:get_children_by_id("progress")[1].value = elapsedseconds
			media:get_children_by_id("progress")[1].max_value = totalseconds
		else
			local hour, min, sec = string.match(total, "(%d+):(%d+):(%d+)")

			local totalseconds = tonumber(hour) * 3600 + tonumber(min) * 60 + tonumber(sec)

			if string.match(elapsed, "(%d+):(%d+):(%d+)") ~= nil then
				local hour, min, sec = string.match(elapsed, "(%d+):(%d+):(%d+)")
				local elapsedseconds = tonumber(hour) * 3600 + tonumber(min) * 60 + tonumber(sec)
			else
				local elapsedseconds = tonumber(elapsed:match("(.*):")) * 60 + tonumber(elapsed:match(":(.*)"))
			end

			media:get_children_by_id("progress")[1].value = elapsedseconds
			media:get_children_by_id("progress")[1].max_value = totalseconds
		end
	end

	if status then
		media:get_children_by_id("pause")[1].image = createicon("pause")
	else
		media:get_children_by_id("pause")[1].image = createicon("play")
	end

	awesome.connect_signal("live::reload", function()
		if cover == "None" then
			coverart = beautiful.calla
		end
		media:get_children_by_id("cover")[1].image = coverart
	end)
end)

@TheKamboy
Copy link
Author

Forgot to mention but even without the progress bar working, there is no more errors

@TheKamboy
Copy link
Author

Ok just edited the code in the comment above and I think me forgetting to turn sec into a number when adding for elapsed and total caused the progress bar to stop working, can't test since I'm at school and currently typing on phone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant