Simple Neovim plugin to stream audio from YouTube.
{
'cockytrumpet/yt_audio.nvim',
init = function()
vim.api.nvim_set_keymap('n', '<leader>yp', ':YAPlay<CR>', { noremap = true, silent = true }) -- prompt for url
vim.api.nvim_set_keymap('n', '<leader>y1', ':YAPlay https://www.youtube.com/watch?v=dQw4w9WgXcQ&pp=ygUJcmljayByb2xs<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>ys', ':YAStop<CR>', { noremap = true, silent = true })
end,
event = 'VeryLazy',
opts = true,
}
opts = {
volume = 50, -- 0-100
icon = "" -- set any font icon or emoji: , 🎧,
notifications = true, -- toggle notifications
ytdlp_args = { -- yt-dlp arguments
"-q",
"--no-warnings",
"-f",
"234",
"-P",
"temp:/tmp",
"--downloader", -- stops '--Frag' files from being written to disk
"ffmpeg",
"-o",
"-",
-- <url>
},
ffplay_args = { -- ffplay arguments
"-i",
"-vn",
"-nodisp",
"-autoexit",
"-loglevel",
"quiet",
-- -volume
-- <0-100>
-- "-"
},
}
Command | Arguments | Keymap | Description |
---|---|---|---|
YTPlay | <url> | user-defined | Start playing (prompt for url if not provided) |
YTStop | user-defined | Stop playing |
The title of the currently playing audio can be retrieved with the get_title function for use in other plugins.
Here is an example for bufferline:
bufferline.setup {
-- other stuff
options = {
custom_areas = {
right = function()
local title = require('yt_audio').get_title()
if title then
-- return { { text = title, guifg = '#FF0000' } }
return { { text = title } }
end
end,
},
},
}