Rewrite vlc.onPlaying handler, fixes #35.

develop
Icedream 2015-11-05 03:02:03 +01:00
parent 38c248e643
commit 1b1f4c0f37
1 changed files with 14 additions and 5 deletions

View File

@ -78,12 +78,21 @@ ts3clientService.on "started", (ts3proc) =>
# VLC event handling # VLC event handling
vlc.onPlaying = () => vlc.onPlaying = () =>
try
# TODO: Check why info is sometimes null, something must be wrong with the "add"/"play" commands here!
# TODO: Do not format as URL in text message if MRL points to local file
item = vlc.playlist.items[vlc.playlist.currentItem]
info = vlcMediaInfo[item.mrl]
url = info?.originalUrl or item.mrl
title = info?.title or item.mrl
ts3query?.sendtextmessage 2, 0, "Now playing [URL=#{url}]#{title}[/URL]."
# Restore audio volume # Restore audio volume
vlc.audio.volume = vlcVolume vlc.audio.volume = vlcVolume
catch e
log.warn "Error in VLC onPlaying handler", e
# TODO: Check why info is sometimes null, something must be wrong with the "add"/"play" commands here!
info = vlcMediaInfo[vlc.playlist.items[vlc.playlist.currentItem].mrl]
ts3query?.sendtextmessage 2, 0, "Now playing [URL=#{info?.originalUrl or vlc.playlist.items[vlc.playlist.currentItem].mrl}]#{info?.title or vlc.playlist.items[vlc.playlist.currentItem].mrl}[/URL]."
vlc.onPaused = () => ts3query?.sendtextmessage 2, 0, "Paused." vlc.onPaused = () => ts3query?.sendtextmessage 2, 0, "Paused."
vlc.onForward = () => ts3query?.sendtextmessage 2, 0, "Fast-forwarding..." vlc.onForward = () => ts3query?.sendtextmessage 2, 0, "Fast-forwarding..."
vlc.onBackward = () => ts3query?.sendtextmessage 2, 0, "Rewinding..." vlc.onBackward = () => ts3query?.sendtextmessage 2, 0, "Rewinding..."