[vlc-commits] http interface can now change and view audio delay
Akash Mehrotra
git at videolan.org
Tue Jun 14 02:00:52 CEST 2011
vlc | branch: master | Akash Mehrotra <mehrotra.akash at gmail.com> | Sun Jun 5 01:21:11 2011 +0530| [dc9c660248d8331d44f38568b2210c1368dc0c48] | committer: Jean-Baptiste Kempf
http interface can now change and view audio delay
Allows http interface to set the playback rate.
Playback rate must be > 0
Set subtitle delay using the http iterface
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dc9c660248d8331d44f38568b2210c1368dc0c48
---
share/lua/http/dialogs/main | 33 ++++++++++++++++++++++++
share/lua/http/js/functions.js | 48 ++++++++++++++++++++++++++++++++++++
share/lua/http/requests/README.txt | 9 ++++++
share/lua/http/requests/status.xml | 15 +++++++++++
4 files changed, 105 insertions(+), 0 deletions(-)
diff --git a/share/lua/http/dialogs/main b/share/lua/http/dialogs/main
index 8de8374..2b92c22 100644
--- a/share/lua/http/dialogs/main
+++ b/share/lua/http/dialogs/main
@@ -98,6 +98,39 @@ sout and playlist .
<img src="images/speaker_mute.png" alt="Mute Volume" />
<span class="btn_text">Mute Volume</span>
</button>
+ <br />
+ Audio Delay:
+ <button id="btn_delay_down" onclick="audiodelay_down();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Decrease Audio Delay by 50ms" >
+ <img src="images/minus.png" alt="Decrease Audio Delay" />
+ <span class="btn_text">Decrease Audio Delay</span>
+ </button>
+ <button id="btn_delay_up" onclick="audiodelay_up();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Increase Audio Delay by 50ms" >
+ <img src="images/plus.png" alt="Increase Audio Delay" />
+ <span class="btn_text">Increase Audio Delay</span>
+ </button>
+ <span id="a_del">(?)</span> ms
+ <br />
+ Playback Speed:
+ <button id="btn_delay_down" onclick="playrate_down();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Decrease playback rate by 0.05x" >
+ <img src="images/minus.png" alt="Decrease Playback Rate" />
+ <span class="btn_text">Decrease Playback Rate</span>
+ </button>
+ <button id="btn_delay_up" onclick="playrate_up();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Increase playback rate by 0.05x" >
+ <img src="images/plus.png" alt="Increase Playback Rate" />
+ <span class="btn_text">Increase Playback Rate</span>
+ </button>
+ <span id="p_rate">(?)</span>x
+ <br/>
+ Advance of subtitles over video:
+ <button id="btn_delay_down" onclick="subdel_down();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Decrease subtitle delay by 50ms" >
+ <img src="images/minus.png" alt="Decrease Subtitle delay" />
+ <span class="btn_text">Decrease Subtitle delay</span>
+ </button>
+ <button id="btn_delay_up" onclick="subdel_up();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Increase subtitle delay by 50ms" >
+ <img src="images/plus.png" alt="Increase Subtitle delay" />
+ <span class="btn_text">Increase Subtitle delay</span>
+ </button>
+ <span id="s_del">(?)</span>ms
</div>
<div id="status">
diff --git a/share/lua/http/js/functions.js b/share/lua/http/js/functions.js
index 9c3f07d..cbd78b1 100644
--- a/share/lua/http/js/functions.js
+++ b/share/lua/http/js/functions.js
@@ -416,6 +416,48 @@ function reset_search()
update_playlist_search('')
}
}
+function audiodelay_down()
+{
+ var curdel = parseFloat(req.responseXML.documentElement.getElementsByTagName( 'audiodelay' )[0].firstChild.data);
+ var curdelnew = curdel - 0.05;
+ curdelnew=curdelnew.toFixed(2);
+ loadXMLDoc( 'requests/status.xml?command=audiodelay&val='+encodeURIComponent(curdelnew), parse_status );
+}
+function audiodelay_up()
+{
+ var curdel = parseFloat(req.responseXML.documentElement.getElementsByTagName( 'audiodelay' )[0].firstChild.data);
+ var curdelnew = curdel + 0.05;
+ curdelnew=curdelnew.toFixed(2);
+ loadXMLDoc( 'requests/status.xml?command=audiodelay&val='+encodeURIComponent(curdelnew), parse_status );
+}
+function playrate_down()
+{
+ var currate = parseFloat(req.responseXML.documentElement.getElementsByTagName( 'rate' )[0].firstChild.data);
+ var curratenew = currate - 0.05;
+ curratenew=curratenew.toFixed(2);
+ loadXMLDoc( 'requests/status.xml?command=rate&val='+encodeURIComponent(curratenew), parse_status );
+}
+function playrate_up()
+{
+ var currate = parseFloat(req.responseXML.documentElement.getElementsByTagName( 'rate' )[0].firstChild.data);
+ var curratenew = currate + 0.05;
+ curratenew=curratenew.toFixed(2);
+ loadXMLDoc( 'requests/status.xml?command=rate&val='+encodeURIComponent(curratenew), parse_status );
+}
+function subdel_down()
+{
+ var curdel = parseFloat(req.responseXML.documentElement.getElementsByTagName( 'subtitledelay' )[0].firstChild.data);
+ var curdelnew = curdel - 0.05;
+ curdelnew=curdelnew.toFixed(2);
+ loadXMLDoc( 'requests/status.xml?command=subdelay&val='+encodeURIComponent(curdelnew), parse_status );
+}
+function subdel_up()
+{
+ var curdel = parseFloat(req.responseXML.documentElement.getElementsByTagName( 'subtitledelay' )[0].firstChild.data);
+ var curdelnew = curdel + 0.05;
+ curdelnew=curdelnew.toFixed(2);
+ loadXMLDoc( 'requests/status.xml?command=subdelay&val='+encodeURIComponent(curdelnew), parse_status );
+}
/**********************************************************************
* Parse xml replies to XMLHttpRequests
@@ -467,6 +509,12 @@ function parse_status()
old_time = new_time;
set_text( 'time', format_time( new_time ) );
set_text( 'length', format_time( length ) );
+ var audio_delay = (parseFloat(req.responseXML.documentElement.getElementsByTagName( 'audiodelay' )[0].firstChild.data).toFixed(2))*1000;
+ set_text( 'a_del', audio_delay );
+ var play_rate = (parseFloat(req.responseXML.documentElement.getElementsByTagName( 'rate' )[0].firstChild.data).toFixed(2));
+ set_text( 'p_rate', play_rate );
+ var subs_delay = (parseFloat(req.responseXML.documentElement.getElementsByTagName( 'subtitledelay' )[0].firstChild.data).toFixed(2))*1000;
+ set_text( 's_del', subs_delay );
if( status.getElementsByTagName( 'volume' ).length != 0 )
set_text( 'volume', Math.floor(status.getElementsByTagName( 'volume' )[0].firstChild.data/5.12)+'%' );
var statetag = status.getElementsByTagName( 'state' );
diff --git a/share/lua/http/requests/README.txt b/share/lua/http/requests/README.txt
index f3a7667..0b19bb6 100644
--- a/share/lua/http/requests/README.txt
+++ b/share/lua/http/requests/README.txt
@@ -50,6 +50,15 @@ status.xml:
> empty playlist:
?command=pl_empty
+> set audio delay
+ ?command=audiodelay&val=<delayinseconds>
+
+> set subtitle delay
+ ?command=subdelay&val=<delayinseconds>
+
+> set playback rate. must be > 0
+ ?command=rate&val=<newplaybackrate>
+
> sort playlist using sort mode <val> and order <id>:
?command=pl_sort&id=<id>&val=<val>
If id=0 then items will be sorted in normal order, if id=1 they will be
diff --git a/share/lua/http/requests/status.xml b/share/lua/http/requests/status.xml
index bbef12d..3900454 100644
--- a/share/lua/http/requests/status.xml
+++ b/share/lua/http/requests/status.xml
@@ -111,6 +111,18 @@ elseif command == "seek" then
common.seek(val)
elseif command == "key" then
common.hotkey("key-"..val)
+elseif command == "audiodelay" then
+ if vlc.object.input() and val then
+ vlc.var.set(vlc.object.input(),"audio-delay",val)
+ end
+elseif command == "rate" then
+ if vlc.object.input() and tonumber(val) >= 0 then
+ vlc.var.set(vlc.object.input(),"rate",val)
+ end
+elseif command == "subdelay" then
+ if vlc.object.input() then
+ vlc.var.set(vlc.object.input(),"spu-delay",val)
+ end
end
local input = nil
@@ -125,6 +137,9 @@ local vout = input and vlc.object.find(input,'vout','child')
?>
<root>
<volume><?vlc print(vlc.volume.get()) ?></volume>
+ <audiodelay><?vlc if input then print(vlc.var.get(input,"audio-delay")) else print (0) end ?></audiodelay>
+ <rate><?vlc if input then print(vlc.var.get(input,"rate")) else print (1) end ?></rate>
+ <subtitledelay><?vlc if input then print(vlc.var.get(input,"spu-delay")) else print (0) end ?></subtitledelay>
<length><?vlc if input then print(math.floor(vlc.var.get(input,"length"))) else print(0) end?></length>
<time><?vlc if input then print(math.floor(vlc.var.get(input,"time"))) else print(0) end?></time>
<state><?vlc print(vlc.playlist.status()) ?></state>
More information about the vlc-commits
mailing list