Playlist auf NAS abspielen - gesamte restliche Zeit der Playlist anzeigen

F

francwalter

Aktives Mitglied
Thread Starter
Dabei seit
25.04.2008
Beiträge
950
Reaktionspunkte
39
Hallo
auf meinem NAS habe ich ein paar Hörbücher. Die liegen als viele mp3-Dateien jeweils in Ordnern.
Die will ich mit meinem Mac OS 10.11.6 abspielen, aber nur abspielen, nicht importieren, wie es iTunes machen würde.
Bisher verwende ich dazu VLC aus dem "Öffnen mit..." Untermenü, da kann man dann den ganzen Ordner als Playlist in VLC laden.

Bildschirmfoto 2021-01-09 um 15.52.04.png

Das geht zwar, aber es wird nicht angezeigt, wie lange die Playlist noch läuft. Nur der aktuelle Track. Sogar die Gesamtspielzeit wird nicht immer korrekt angezeigt, weil VLC nicht alle Titel gleich einliest über das Netz und die Gesamtspielzeit dann manchmal nicht mehr aktualisiert, wenn alle Tracks in die Playlist eingelesen sind.
Also habe ich mal Cog versucht, in der letzten Version für 10.11.6, der 1148 nämlich.
Leider wird dort auch nur die aktuelle Trackzeit oder Track-Restzeit angezeigt.
Zudem taucht Cog nicht in der Liste der "Öffnen mit..." Programme auf.
Immerhin ist die Gesamtplaylistdauer korrekt, die liest Cog zügig und richtig ein:

Bildschirmfoto 2021-01-09 um 16.08.38.png

Kennt jemand ein Medienabspielprogramm, das verbleibende Spielzeit von Playlists aus dem Netzwerk anzeigen kann?

Danke.
franc
 
Ich habe natürlich weiter gesucht und fand über Total Duration of Playlist in VLC Player? (auf superuser) auf Github ein Plugin für VLC, das immerhin die Playlist-Dauer (nochmal) anzeigen kann:
vlc-total-playlist-duration-extension
Da habe ich mal rein geschaut und kam darüber auf die VLC-Funktionen für Playlists:
Code:
...
Playlist
--------
playlist.prev(): Play previous track.
playlist.next(): Play next track.
playlist.skip( n ): Skip n tracks.
playlist.play(): Play.
playlist.pause(): Pause.
playlist.stop(): Stop.
playlist.clear(): Clear the playlist.
playlist.get_repeat(): Get current repeat mode.
playlist.repeat_( [status] ): Toggle item repeat or set to specified value.
playlist.get_loop(): Get current loop mode.
playlist.loop( [status] ): Toggle playlist loop or set to specified value.
playlist.get_random(): Get current random mode.
playlist.random( [status] ): Toggle playlist random or set to specified value.
playlist.goto( id ): Go to specified track.
playlist.add( ... ): Add a bunch of items to the playlist.
  The playlist is a table of playlist items.
  A playlist item has the following members:
      .path: the item's full path / URL
      .name: the item's name in playlist (OPTIONAL)
      .title: the item's Title (OPTIONAL, meta data)
      .artist: the item's Artist (OPTIONAL, meta data)
      .genre: the item's Genre (OPTIONAL, meta data)
      .copyright: the item's Copyright (OPTIONAL, meta data)
      .album: the item's Album (OPTIONAL, meta data)
      .tracknum: the item's Tracknum (OPTIONAL, meta data)
      .description: the item's Description (OPTIONAL, meta data)
      .rating: the item's Rating (OPTIONAL, meta data)
      .date: the item's Date (OPTIONAL, meta data)
      .setting: the item's Setting (OPTIONAL, meta data)
      .url: the item's URL (OPTIONAL, meta data)
      .language: the item's Language (OPTIONAL, meta data)
      .nowplaying: the item's NowPlaying (OPTIONAL, meta data)
      .publisher: the item's Publisher (OPTIONAL, meta data)
      .encodedby: the item's EncodedBy (OPTIONAL, meta data)
      .arturl: the item's ArtURL (OPTIONAL, meta data)
      .trackid: the item's TrackID (OPTIONAL, meta data)
      .options: a list of VLC options (OPTIONAL)
                example: .options = { "run-time=60" }
      .duration: stream duration in seconds (OPTIONAL)
      .meta: custom meta data (OPTIONAL, meta data)
             A .meta field is a table of custom meta key value pairs.
             example: .meta = { ["GVP docid"] = "-5784010886294950089", ["GVP version] = "1.1", Hello = "World!" }
  Invalid playlist items will be discarded by VLC.
playlist.enqueue( ... ): like playlist.add() except that track isn't played.
playlist.get( [what, [tree]] ): Get the playlist.
  If "what" is a number, then this will return the corresponding playlist
  item's playlist hierarchy. If it is "normal" or "playlist", it will
  return the normal playlist. If it is "ml" or "media library", it will
  return the media library. If it is "root" it will return the full playlist.
  If it is a service discovery module's name, it will return that service
  discovery's playlist. If it is any other string, it won't return anything.
  Else it will return the full playlist.
  The second argument, "tree", is optional. If set to true or unset, the
  playlist will be returned in a tree layout. If set to false, the playlist
  will be returned using the flat layout.
  Each playlist item returned will have the following members:
      .item: The input item.
      .id: The item's id.
      .flags: a table with the following members if the corresponding flag is
              set:
          .disabled
          .ro
      .name:
      .path:
      .duration: (-1 if unknown)
      .nb_played:
playlist.current(): return the current playlist item id
playlist.current_item(): return the current playlist item (same structure as player.item())
playlist.sort( key ): sort the playlist according to the key.
  Key must be one of the followings values: 'id', 'title', 'title nodes first',
                                            'artist', 'genre', 'random', 'duration',
                                            'title numeric' or 'album'.
playlist.status(): return the playlist status: 'stopped', 'playing', 'paused' or 'unknown'.
playlist.delete( id ): check if item of id is in playlist and delete it. returns -1 when invalid id.
playlist.move( id_item, id_where ): take id_item and if id_where has children, it put it as first children,
   if id_where don't have children, id_item is put after id_where in same playlist. returns -1 when invalid ids.
...
Interessant daraus mindestens: playlist.current_item() in Verbindung mit .duration

Im Plugin steht ja:

Code:
...
function get_playlist_duration()
  local total = 0
  for key, value in pairs(vlc.playlist.get("playlist", false).children) do
    if value.duration ~= -1 then
      total = total + value.duration
    end
  end
  time_label:set_text(seconds_to_time(total))
  return total
end
...

Da lässt sich doch vielleicht was dazu programmieren...

Also damit:
Code:
function get_playlist_duration()
  local total = 0
  for key, value in pairs(vlc.playlist.get("playlist", false).children) do
    if value.duration ~= -1 then
      total = total + value.duration
    end
    if value.id == vlc.playlist.current() then
      break
    end
  end
  time_label:set_text(seconds_to_time(total))
  return total
end
zeigt die Extension schon mal wie viel Zeit vergangen ist bisher, das ist schon mal ein Anfang, jetzt muss ich das einfach noch von der Gesamtzeit abziehen...
 
Zuletzt bearbeitet:
OK, ich habs:


Code:
-- Playlist total duration
-- Simple extension that shows the current playlist's total duration

-- Lua scripts are tried in alphabetical order in the user's VLC config directory
-- lua/{playlist,meta,intf}/ subdirectory on Windows and Mac OS X or in the user's
-- local share directory (~/.local/share/vlc/lua/... on linux), then in the global
-- VLC lua/{playlist,meta,intf}/ directory.

-- 2021-01-10: extended to show the remaining time of the whole playlist _and_ the whole playlist time:
-- <remaining time in total playlist> / <total playlist time> e.g.:
-- 01:26:22 / 02:58:01

-- ToDo: auto refresh

-- original code from:
-- https://github.com/bentrevor/vlc-total-playlist-duration-extension

-- Extension description
function descriptor()
    return { title = "Playlist total duration" ;
             version = "1.2" ;
             author = "Ben Trevor" ;
             shortdesc = "Displays dialog box with played, remaining and current playlist's total duration";
             description = "Displays a dialog box with the played time, the remaining time and the total play time of a playlist. Refresh only on Button press" ;
             capabilities = { }
        }
end

-- Activation hook
function activate()
  window = vlc.dialog("Playlist: played / remaining / total")
  window:add_button("refresh", update_duration, 1, 1, 1, 1)
  time_label = window:add_label("", 2, 1, 1, 1)
  get_playlist_duration()
  window:show()
end

function update_duration()
  get_playlist_duration()
end

function get_playlist_duration()
  -- playing time of total playlist
  local total = 0
  -- played time in actual track
  local track_played_time = 0
  -- played time in total playlist
  local act_pl_position = 0
  -- remaining time in total playlist
  local rem_pl_time = 0
 
  -- gives a float between 0 and 1 for the actual position of the actual track, unfortunately...
  -- ...the function: vlc.player.get_position() is not working, neither is vlc.player.get_time()
  track_played_time = vlc.var.get(vlc.object.input(), "position")
 
  -- iterates the whole playlist
  for key, value in pairs(vlc.playlist.get("playlist", false).children) do
 
    -- if the actual track is reached in playlist, get the played time in playlist
    if value.id == vlc.playlist.current() then
      -- duration of actual track * position in actual track (float between 0 and 1) + total (since this track)
      act_pl_position = total + track_played_time * value.duration
    end
    -- if the duration is not available it is -1
    if value.duration ~= -1 then
      total = total + value.duration
    end
  end
  -- remaining playing time is total - actual playing time position in playlist
  rem_pl_time = total - act_pl_position
 
  -- actual playing time in playlist / remaining time in playlist / total time in playlist (hh:mm:ss / hh:mm:ss / hh:mm:ss)
  time_label:set_text(seconds_to_time(act_pl_position) .. " / " .. seconds_to_time(rem_pl_time) .. " / " .. seconds_to_time(total))
  return total
end


-- convert time to readable format (hh:mm:ss)
function seconds_to_time(seconds)
  local hours = math.floor(seconds / 3600)
  local minutes = math.floor((seconds % 3600) / 60)
  local seconds = math.floor(seconds % 60)

  -- leading 0 for 1 to 9
  if hours < 10 then
    hours = "0" .. hours
  end
  if minutes < 10 then
    minutes = "0" .. minutes
  end
  if seconds < 10 then
    seconds = "0" .. seconds
  end
  -- returns hh:mm:ss 
  return hours .. ":" .. minutes .. ":" .. seconds
end

-- Deactivation hook
function deactivate()
end

-- stop the extension when the dialog window is closed
function close()
  vlc.deactivate()
end

-- stops debug error messages, which stops vlc from crashing.  I'm still not sure why...
function meta_changed()
end

Das ist das komplette Skript von Ben Trevor (s.o.) das ich etwas erweitert habe.
Man muss es auf dem Mac in:

/Users/<user>/Library/Application Support/org.videolan.vlc/lua/extensions/simple-time.lua

speichern, falls die Verzeichnisse nicht existieren, muss man sie anlegen (also lua, extensions - das org.videolan.vlc wird wohl schon exisiteren, wenn man den VLC mal benutzt hat, denke ich).
Dann ruft man die Extension auf über das Menü:
VLC > Extensions > Playlist total duration
und kriegt dann etwa so ein Fensterle:

Bildschirmfoto 2021-01-10 um 14.20.58.png
Noch zu tun wäre ein automatischer Refresh, das geht momentan nur über den Button, das ist etwas arg spartanisch.
Aber ich habe noch nie in Lua programmiert und weiß auf Anhieb (noch) nicht, wie man das insbesondere bei einer VLC Erweiterung macht.
Also dass es z.B. dann auch wieder sauber aufhört, wenn man das Fenster schließt und nichts zum Abstürzen bringt etc.
Ist sicher nicht schwer...
bald mehr...
 
  • Gefällt mir
Reaktionen: Johanna K und ruerueka
Zurück
Oben Unten