Commit dc9c6602 authored by Akash Mehrotra's avatar Akash Mehrotra Committed by 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: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent cc2bd3bd
...@@ -98,6 +98,39 @@ sout and playlist . ...@@ -98,6 +98,39 @@ sout and playlist .
<img src="images/speaker_mute.png" alt="Mute Volume" /> <img src="images/speaker_mute.png" alt="Mute Volume" />
<span class="btn_text">Mute Volume</span> <span class="btn_text">Mute Volume</span>
</button> </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>
<div id="status"> <div id="status">
......
...@@ -416,6 +416,48 @@ function reset_search() ...@@ -416,6 +416,48 @@ function reset_search()
update_playlist_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 * Parse xml replies to XMLHttpRequests
...@@ -467,6 +509,12 @@ function parse_status() ...@@ -467,6 +509,12 @@ function parse_status()
old_time = new_time; old_time = new_time;
set_text( 'time', format_time( new_time ) ); set_text( 'time', format_time( new_time ) );
set_text( 'length', format_time( length ) ); 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 ) if( status.getElementsByTagName( 'volume' ).length != 0 )
set_text( 'volume', Math.floor(status.getElementsByTagName( 'volume' )[0].firstChild.data/5.12)+'%' ); set_text( 'volume', Math.floor(status.getElementsByTagName( 'volume' )[0].firstChild.data/5.12)+'%' );
var statetag = status.getElementsByTagName( 'state' ); var statetag = status.getElementsByTagName( 'state' );
......
...@@ -50,6 +50,15 @@ status.xml: ...@@ -50,6 +50,15 @@ status.xml:
> empty playlist: > empty playlist:
?command=pl_empty ?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>: > sort playlist using sort mode <val> and order <id>:
?command=pl_sort&id=<id>&val=<val> ?command=pl_sort&id=<id>&val=<val>
If id=0 then items will be sorted in normal order, if id=1 they will be If id=0 then items will be sorted in normal order, if id=1 they will be
......
...@@ -111,6 +111,18 @@ elseif command == "seek" then ...@@ -111,6 +111,18 @@ elseif command == "seek" then
common.seek(val) common.seek(val)
elseif command == "key" then elseif command == "key" then
common.hotkey("key-"..val) 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 end
local input = nil local input = nil
...@@ -125,6 +137,9 @@ local vout = input and vlc.object.find(input,'vout','child') ...@@ -125,6 +137,9 @@ local vout = input and vlc.object.find(input,'vout','child')
?> ?>
<root> <root>
<volume><?vlc print(vlc.volume.get()) ?></volume> <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> <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> <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> <state><?vlc print(vlc.playlist.status()) ?></state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment