howto:vlc-playlist-from-file
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| howto:vlc-playlist-from-file [2021/12/28 14:39] – Wulf Rajek | howto:vlc-playlist-from-file [2023/05/29 11:55] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== VLC ====== | ||
| + | |||
| + | ====== VLC no audio ====== | ||
| + | |||
| + | Change output module in Tools -> Preferences -> Audio from Auto to Pulseaudio or Alsa. | ||
| + | |||
| + | alternative edit config file: | ||
| + | < | ||
| + | vi ~/ | ||
| + | </ | ||
| + | < | ||
| + | # Audio output module (string) | ||
| + | aout=pulse | ||
| + | </ | ||
| + | |||
| + | ====== Associate VLC to webm videos ====== | ||
| + | Gnome uses two lists to register applications to file types located in: | ||
| + | * / | ||
| + | * / | ||
| + | * ~/ | ||
| + | < | ||
| + | #manually | ||
| + | sudo vi / | ||
| + | sudo vi / | ||
| + | vi ~/ | ||
| + | |||
| + | #or via sed: | ||
| + | sudo sed -i ' | ||
| + | sudo sed -i ' | ||
| + | sudo sed -i ' | ||
| + | sed -i ' | ||
| + | sed -i ' | ||
| + | </ | ||
| + | |||
| + | |||
| ====== VLC Playlist from file ====== | ====== VLC Playlist from file ====== | ||
| Line 11: | Line 46: | ||
| You may want to activate the loop option in VLC preferences if VLC is configured to play the next track automatically. (Tools -> Preferences -> Show all settings -> Playlist -> Repeat current item) | You may want to activate the loop option in VLC preferences if VLC is configured to play the next track automatically. (Tools -> Preferences -> Show all settings -> Playlist -> Repeat current item) | ||
| + | |||
| + | or edit ~/ | ||
| + | < | ||
| + | vi ~/ | ||
| + | </ | ||
| + | < | ||
| + | # Repeat current item (boolean) | ||
| + | repeat=1 | ||
| + | </ | ||
| ==== Linux ==== | ==== Linux ==== | ||
| Copy vlc.sh in ~/ | Copy vlc.sh in ~/ | ||
| + | < | ||
| + | sed -i ' | ||
| + | </ | ||
| - | + | note: source from github adjusted to sort numbers as Versions like nemo file manager does. | |
| - | < | + | < |
| #!/bin/bash | #!/bin/bash | ||
| + | shopt -s nocaseglob | ||
| shopt -s extglob | shopt -s extglob | ||
| - | extensions=' | + | extensions=' |
| # kill other instances of vlc to keep playlist clean (one-instance mode) | # kill other instances of vlc to keep playlist clean (one-instance mode) | ||
| Line 27: | Line 75: | ||
| # launch empty vlc if no argument provided | # launch empty vlc if no argument provided | ||
| if [ -z " | if [ -z " | ||
| - | vlc; exit | + | |
| fi | fi | ||
| Line 36: | Line 84: | ||
| # count files with matching extension, and get position of filename in current directory | # count files with matching extension, and get position of filename in current directory | ||
| - | n=$(ls " | + | n=$(ls " |
| - | pos=$(ls " | + | pos=$(ls " |
| # if the filename does not have one of the extension above, launch vlc with provided filename | # if the filename does not have one of the extension above, launch vlc with provided filename | ||
| if [ -z " | if [ -z " | ||
| - | vlc -- " | + | |
| - | exit | + | exit |
| fi | fi | ||
| # change positions in playlist such as the first element is the opened file | # change positions in playlist such as the first element is the opened file | ||
| - | ls " | + | ls " |
| - | ls " | + | ls " |
| # launch playlist | # launch playlist | ||
| - | IFS=$' | + | IFS=$' |
| </ | </ | ||
| Line 73: | Line 121: | ||
| powershell -File %USERPROFILE%\vlc.ps1 %1 | powershell -File %USERPROFILE%\vlc.ps1 %1 | ||
| </ | </ | ||
| - | < | + | < |
| Param([string]$filename) | Param([string]$filename) | ||
| Line 104: | Line 152: | ||
| & $vlcPath $(Get-Content $Env: | & $vlcPath $(Get-Content $Env: | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ====== VLC Delete file option ====== | ||
| + | |||
| + | So put the file in ~/ | ||
| + | |||
| + | When you start VLC you get a new menu item: View > Detetefile. It is this last step I was missing. | ||
| + | |||
| + | It now searches for a dir called .waste in the dir of the file and any (grand*)parent dirs, and moves the file there. So you need to create a dir called .waste. | ||
| + | |||
| + | When you start VLC you get a new menu item: View > Move currently playing file into wastebasket. | ||
| + | |||
| + | <code lua WasteBasket.lua> | ||
| + | --[[ | ||
| + | INSTALLATION (create directories if they do not exist): | ||
| + | - put the file in the VLC subdir / | ||
| + | * Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\ | ||
| + | * Windows (current user): %APPDATA%\VLC\lua\extensions\ | ||
| + | * Linux (all users): / | ||
| + | * Linux (current user): ~/ | ||
| + | * Mac OS X (all users): / | ||
| + | - Restart VLC. | ||
| + | - The extension can then be found in the menu: | ||
| + | View > Move current playing file into wastebasket | ||
| + | ]]-- | ||
| + | |||
| + | --[[ Extension description ]] | ||
| + | |||
| + | function descriptor() | ||
| + | return { title = " | ||
| + | version = " | ||
| + | author = "Mark Morschhäuser/ | ||
| + | shortdesc = "Move current playing file into wastebasket"; | ||
| + | description = "< | ||
| + | .. "When you're playing a file, use Wastebasket to " | ||
| + | .. " | ||
| + | .. "< | ||
| + | .. "< | ||
| + | .. "in the dir of the file and all parent dirs of that."; | ||
| + | url = " | ||
| + | } | ||
| + | end | ||
| + | |||
| + | --[[ Hooks ]] | ||
| + | |||
| + | -- Activation hook | ||
| + | function activate() | ||
| + | local filename, | ||
| + | -- create waste directory if it doesn' | ||
| + | if(not directory_exists(wdir)) then | ||
| + | -- escaping single quote while surrounding dir in single quotes for dirs with spaces | ||
| + | os.execute(" | ||
| + | wdir = dirname(filename) .. wdir | ||
| + | end | ||
| + | if(directory_exists(wdir)) then | ||
| + | d = vlc.dialog(" | ||
| + | d: | ||
| + | d: | ||
| + | d: | ||
| + | d:show() | ||
| + | else | ||
| + | d = vlc.dialog(" | ||
| + | d: | ||
| + | d: | ||
| + | d:show() | ||
| + | end | ||
| + | vlc.msg.dbg(" | ||
| + | end | ||
| + | |||
| + | function filename_dst_wastedir() | ||
| + | -- get the current playing file | ||
| + | local item = vlc.input.item() | ||
| + | -- extract its URI | ||
| + | local uri = item:uri() | ||
| + | -- decode %foo stuff from the URI | ||
| + | local filename = vlc.strings.decode_uri(uri) | ||
| + | -- remove ' | ||
| + | filename = string.sub(filename, | ||
| + | |||
| + | -- find .waste in parent dirs | ||
| + | local wdir = wastedir(dirname(filename)) | ||
| + | return filename, | ||
| + | end | ||
| + | |||
| + | function wastedir(dir) | ||
| + | -- recursively search for .waste in parent dir | ||
| + | |||
| + | vlc.msg.dbg(" | ||
| + | local wdir = dir .. "/" | ||
| + | if directory_exists(wdir) then | ||
| + | | ||
| + | | ||
| + | end | ||
| + | -- try the parent dir | ||
| + | local parent = dirname(dir) | ||
| + | if(parent == dir) then | ||
| + | -- we have reached root (/) | ||
| + | -- return wdir (which does not exist) | ||
| + | return wdir | ||
| + | end | ||
| + | vlc.msg.dbg(" | ||
| + | if directory_exists(parent) then | ||
| + | return wastedir(parent) | ||
| + | else | ||
| + | return parent | ||
| + | end | ||
| + | end | ||
| + | |||
| + | function directory_exists(dir) | ||
| + | -- Simple checker if dir exists | ||
| + | -- shell quote the dirname | ||
| + | dir, _ = dir: | ||
| + | dir, _ = dir: | ||
| + | return os.execute(" | ||
| + | end | ||
| + | |||
| + | function deactivate() | ||
| + | -- Deactivation hook | ||
| + | vlc.msg.dbg(" | ||
| + | vlc.deactivate() | ||
| + | end | ||
| + | |||
| + | function close() | ||
| + | deactivate() | ||
| + | end | ||
| + | |||
| + | --- Function equivalent to basename in POSIX systems | ||
| + | --@param str the path string | ||
| + | function basename(str) | ||
| + | local name = string.gsub(str, | ||
| + | return name | ||
| + | end | ||
| + | |||
| + | function dirname(str) | ||
| + | local name = string.gsub(str, | ||
| + | return name | ||
| + | end | ||
| + | |||
| + | function delete() | ||
| + | local filename, | ||
| + | if(directory_exists(wdir)) then | ||
| + | vlc.msg.dbg(" | ||
| + | local retval, err = os.rename(filename, | ||
| + | if(retval == nil) then | ||
| + | -- error handling; if moving failed, print why | ||
| + | vlc.msg.dbg(" | ||
| + | end | ||
| + | else | ||
| + | d = vlc.dialog(" | ||
| + | d: | ||
| + | d: | ||
| + | d:show() | ||
| + | end | ||
| + | close() | ||
| + | end | ||
| + | |||
| + | -- This empty function is there, because vlc pested me otherwise | ||
| + | function meta_changed() | ||
| + | end | ||
| + | |||
| + | </ | ||
| + | |||
| + | https:// | ||
| + | <code lua delete.lua> | ||
| + | --[[ | ||
| + | Copyright 2015-2019 surrim | ||
| + | |||
| + | This program is free software: you can redistribute it and/or modify | ||
| + | it under the terms of the GNU General Public License as published by | ||
| + | the Free Software Foundation, either version 3 of the License, or | ||
| + | (at your option) any later version. | ||
| + | |||
| + | This program is distributed in the hope that it will be useful, | ||
| + | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| + | GNU General Public License for more details. | ||
| + | |||
| + | You should have received a copy of the GNU General Public License | ||
| + | along with this program. | ||
| + | ]]-- | ||
| + | |||
| + | function descriptor() | ||
| + | return { | ||
| + | title = "VLC Delete"; | ||
| + | version = " | ||
| + | author = " | ||
| + | url = " | ||
| + | shortdesc = "& | ||
| + | description = [[ | ||
| + | < | ||
| + | When you're playing a file, use VLC Delete to | ||
| + | delete the current file from your playlist and < | ||
| + | This extension has been tested on GNU Linux with VLC 2.1.5.< | ||
| + | The author is not responsible for damage caused by this extension. | ||
| + | ]]; | ||
| + | } | ||
| + | end | ||
| + | |||
| + | function fileExists(file) | ||
| + | return io.popen(" | ||
| + | end | ||
| + | |||
| + | function sleep(seconds) | ||
| + | local t0 = os.clock() | ||
| + | local tOriginal = t0 | ||
| + | while os.clock() - t0 <= seconds and os.clock() >= tOriginal do end | ||
| + | end | ||
| + | |||
| + | function windowsDelete(file, | ||
| + | if not fileExists(" | ||
| + | for i = trys, 1, -1 | ||
| + | do | ||
| + | retval, err = os.remove(file) | ||
| + | --retval, err = os.execute(" | ||
| + | if retval == true then | ||
| + | return true | ||
| + | end | ||
| + | sleep(pause) | ||
| + | end | ||
| + | return {nil, " | ||
| + | end | ||
| + | |||
| + | function removeItem() | ||
| + | local id = vlc.playlist.current() | ||
| + | vlc.playlist.delete(id) | ||
| + | vlc.playlist.gotoitem(id + 1) | ||
| + | vlc.deactivate() | ||
| + | end | ||
| + | |||
| + | function activate() | ||
| + | local item = vlc.input.item() | ||
| + | local uri = item:uri() | ||
| + | uri = string.gsub(uri, | ||
| + | uri = vlc.strings.decode_uri(uri) | ||
| + | vlc.msg.info(" | ||
| + | |||
| + | if (package.config: | ||
| + | retval, err = os.execute(" | ||
| + | if (retval ~= nil) then | ||
| + | uri = "/" | ||
| + | retval, err = os.execute(" | ||
| + | else | ||
| + | retval, err = os.execute(" | ||
| + | if (retval ~= nil) then | ||
| + | uri = "/" | ||
| + | retval, err = os.execute(" | ||
| + | end | ||
| + | end | ||
| + | if (retval ~= nil) then removeItem() end | ||
| + | else -- windows | ||
| + | removeItem() -- remove from playlist first so the file isnt locked by vlc | ||
| + | uri = string.gsub(uri, | ||
| + | retval, err = windowsDelete(uri, | ||
| + | end | ||
| + | |||
| + | if (retval == nil) then | ||
| + | vlc.msg.info(" | ||
| + | d = vlc.dialog(" | ||
| + | d: | ||
| + | d: | ||
| + | d: | ||
| + | d:show() | ||
| + | end | ||
| + | end | ||
| + | |||
| + | function click_ok() | ||
| + | d:delete() | ||
| + | vlc.deactivate() | ||
| + | end | ||
| + | |||
| + | function deactivate() | ||
| + | vlc.deactivate() | ||
| + | end | ||
| + | |||
| + | function close() | ||
| + | deactivate() | ||
| + | end | ||
| + | |||
| + | function meta_changed() | ||
| + | end | ||
| + | </ | ||
| + | |||
| + | https:// | ||
| + | |||
| + | |||
howto/vlc-playlist-from-file.1640702397.txt.gz · Last modified: (external edit)