Skip to content

Commit

Permalink
resolved #12, resolved #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Commandcracker committed May 1, 2023
1 parent 94c496b commit ad79a0a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
20 changes: 17 additions & 3 deletions src/lib/youcubeapi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,21 @@ function Buffer.new(filler, size)
return self
end

local currnt_palette = {}

for i = 0, 15 do
local r,g,b = term.getPaletteColour(2 ^ i)
currnt_palette[i] = {r,g,b}
end

local function reset_term()
for i = 0, 15 do
term.setPaletteColor(2 ^ i, term.nativePaletteColor(2 ^ i))
term.setPaletteColor(
2 ^ i,
currnt_palette[i][1],
currnt_palette[i][2],
currnt_palette[i][3]
)
end
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
Expand All @@ -498,7 +510,7 @@ end
and [sanjuuni/websocket-player.lua](https://github.com/MCJack123/sanjuuni/blob/30dcabb4b56f1eb32c88e1bce384b0898367ebda/websocket-player.lua)
@tparam Buffer buffer filled with frames
]]
local function play_vid(buffer, string_unpack)
local function play_vid(buffer, force_fps, string_unpack)
if not string_unpack then
string_unpack = string.unpack
end
Expand All @@ -510,6 +522,8 @@ local function play_vid(buffer, string_unpack)
end

local fps = tonumber(buffer:next())
if force_fps then fps = force_fps end

-- Adjust buffer size
buffer.size = math.ceil(fps) * 2

Expand Down Expand Up @@ -596,7 +610,7 @@ return {
--- "Metadata" - [YouCube API](https://commandcracker.github.io/YouCube/) Version
_API_VERSION = "0.0.0-poc.1.0.0",
--- "Metadata" - Library Version
_VERSION = "0.0.0-poc.1.3.1",
_VERSION = "0.0.0-poc.1.4.0",
--- "Metadata" - Description
_DESCRIPTION = "Library for accessing YouCub's API",
--- "Metadata" - Homepage / Url
Expand Down
21 changes: 17 additions & 4 deletions src/youcube.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Github Repository: https://github.com/Commandcracker/YouCube
License: GPL-3.0
]]

local _VERSION = "0.0.0-poc.1.0.0"
local _VERSION = "0.0.0-poc.1.1.0"

-- Libraries - OpenLibrarieLoader v1.0.0 --

Expand Down Expand Up @@ -112,8 +112,16 @@ parser:flag "--lp" "--loop-playlist"
:target "loop_playlist"
:action "store_true"

parser:option "--fps"
:description "Force sanjuuni to use a specified frame rate"
:target "force_fps"

local args = parser:parse { ... }

if args.force_fps then
args.force_fps = tonumber(args.force_fps)
end

if args.volume then
args.volume = tonumber(args.volume)
if args.volume == nil then
Expand Down Expand Up @@ -188,7 +196,7 @@ end
-- update check --

local function get_versions()
local url = "https://raw.githubusercontent.com/Commandcracker/YouCube/main/versions.json"
local url = "https://raw.githubusercontent.com/CC-YouCube/installer/main/versions.json"

-- Check if the URL is valid
local ok, err = http.checkURL(url)
Expand Down Expand Up @@ -427,7 +435,12 @@ local function play(url)
-- Fill Buffers
while true do
os.queueEvent("youcube:fill_buffers")
os.pullEvent()

local event = os.pullEventRaw()

if event == "terminate" then
libs.youcubeapi.reset_term()
end

if not args.no_audio then
audio_buffer:fill()
Expand Down Expand Up @@ -455,7 +468,7 @@ local function play(url)
end

os.queueEvent("youcube:vid_playing", data)
libs.youcubeapi.play_vid(video_buffer, string_unpack)
libs.youcubeapi.play_vid(video_buffer, args.force_fps, string_unpack)
os.queueEvent("youcube:vid_eof", data)
end
end,
Expand Down

0 comments on commit ad79a0a

Please sign in to comment.