]> git.sesse.net Git - vlc/commitdiff
Merge branch 'master' of git://git.videolan.org/vlc
authorSteinar H. Gunderson <steinar+vlc@gunderson.no>
Sat, 2 Oct 2010 09:47:21 +0000 (11:47 +0200)
committerSteinar H. Gunderson <steinar+vlc@gunderson.no>
Sat, 2 Oct 2010 09:47:21 +0000 (11:47 +0200)
share/lua/http/requests/README.txt
share/lua/http/requests/status.xml
share/lua/intf/modules/common.lua
src/playlist/control.c

index a4cfacbeeaed3349770b7e0fe22ac454c7c26857..c287acf69050762f5304b805a7795546ca3516fe 100644 (file)
@@ -23,7 +23,7 @@ status.xml:
 > add <mrl> to playlist:
   ?command=in_enqueue&input=<mrl>
 
-> play playlist item <id>:
+> play playlist item <id>. If <id> is omitted, play last active item:
   ?command=pl_play&id=<id>
 
 > toggle pause. If current state was 'stop', play item <id>:
index 123861fea7b406e14f82c5b115d4eec3d81d4cd3..6581c80cdf6797341bb4a9549dfb3254786dfbeb 100644 (file)
@@ -55,7 +55,11 @@ if command == "in_play" then
 elseif command == "in_enqueue" then
   vlc.playlist.enqueue({{path=stripslashes(input),options=options}})
 elseif command == "pl_play" then
-  vlc.playlist.goto(id)
+  if id == -1 then
+    vlc.playlist.play()
+  else
+    vlc.playlist.goto(id)
+  end
 elseif command == "pl_pause" then
   vlc.playlist.pause()
 elseif command == "pl_stop" then
index b3fef02f112e77d7755b44652a60358a1a3684d7..a6da379fad0e996249d7fa978c32ae47a33e56a4 100644 (file)
@@ -86,13 +86,56 @@ function realpath(path)
     return string.gsub(string.gsub(string.gsub(string.gsub(path,"/%.%./[^/]+","/"),"/[^/]+/%.%./","/"),"/%./","/"),"//","/")
 end
 
+-- parse the time from a string and return the seconds
+-- time format: [+ or -][<int><H or h>:][<int><M or m or '>:][<int><nothing or S or s or ">]
+function parsetime(timestring)
+    local seconds = 0
+    local hourspattern = "(%d+)[hH]"
+    local minutespattern = "(%d+)[mM']"
+    local secondspattern = "(%d+)[sS\"]?$"
+
+    local _, _, hoursmatch = string.find(timestring, hourspattern)
+    if hoursmatch ~= nil then
+        seconds = seconds + tonumber(hoursmatch) * 3600
+    end
+    local _, _, minutesmatch = string.find(timestring, minutespattern)
+    if minutesmatch ~= nil then
+        seconds = seconds + tonumber(minutesmatch) * 60
+    end
+    local _, _, secondsmatch = string.find(timestring, secondspattern)
+    if secondsmatch ~= nil then
+        seconds = seconds + tonumber(secondsmatch)
+    end
+
+    if string.sub(timestring,1,1) == "-" then
+        seconds = seconds * -1
+    end
+
+    return seconds
+end
+
 -- seek
 function seek(value)
     local input = vlc.object.input()
-    if string.sub(value,#value)=="%" then
-        vlc.var.set(input,"position",tonumber(string.sub(value,1,#value-1))/100.)
-    else
-        vlc.var.set(input,"time",tonumber(value))
+    if input ~= nil and value ~= nil then
+        if string.sub(value,-1) == "%" then
+            local number = tonumber(string.sub(value,1,-2))
+            if number ~= nil then
+                local posPercent = tonumber( string.sub(value,1,-2))/100.
+                if string.sub(value,1,1) == "+" or string.sub(value,1,1) == "-" then
+                    vlc.var.set(input,"position",vlc.var.get(input,"position") + posPercent)
+                else
+                    vlc.var.set(input,"position",posPercent)
+                end
+            end
+        else
+            local posTime = parsetime(value)
+            if string.sub(value,1,1) == "+" or string.sub(value,1,1) == "-" then
+                vlc.var.set(input,"time",vlc.var.get(input,"time") + posTime)
+            else
+                vlc.var.set(input,"time",posTime)
+            end
+        end
     end
 end
 
index 38ddf485646668a97440732351a857bd6b2a64f0..c2f8171f0f073ec1d9404d6d9b9c196652db91fa 100644 (file)
@@ -158,9 +158,10 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
 
     case PLAYLIST_PAUSE:
         if( !pl_priv(p_playlist)->p_input )
-        {    /* FIXME: is this really useful without input? */
-             pl_priv(p_playlist)->status.i_status = PLAYLIST_PAUSED;
-             break;
+        {   /* FIXME: is this really useful without input? */
+            pl_priv(p_playlist)->status.i_status = PLAYLIST_PAUSED;
+            /* return without notifying the playlist thread as there is nothing to do */
+            return VLC_SUCCESS;
         }
 
         if( var_GetInteger( pl_priv(p_playlist)->p_input, "state" ) == PAUSE_S )