def get_time(request): c = Controller() if c.status == VLC_STATUS_STOPPED or c.status == VLC_STATUS_PAUSED: return HttpResponse(0) length = c.get_length() if length == 0: return HttpResponse(0) time = c.get_time() return HttpResponse(100*time/length)
def select(request): if request.method == "POST": controller = Controller() filename = request.POST["filename"] dirname = request.POST["dirname"] if not controller.alive: moviepath = os.path.join(dirname, filename).encode(ENCODING) cwd, vlc = os.path.split(VLC_PATH) os.chdir(cwd) command = vlc + ' -vvv "%s"' % moviepath + OPTION if os.name == "nt": command = shlex.split(command) # windows p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) cache.set("pid", p.pid, 86400*365) # 24h atexit.register(kill) import time time.sleep(0.5) controller = Controller() controller.clear() moviepath = os.path.join(dirname, filename).encode("utf-8") controller.enqueue(moviepath) if filename == controller.get_filename(): controller.pause() return HttpResponse()
def control(request): if request.method =="POST": c = Controller() command = request.POST["command"].encode("utf-8") if not "seek" in command: getattr(c, command)() else: _, percent = command.split(" ") c.seek(int(percent)) c.logout() if command == "shutdown": cache.delete("pid") return HttpResponse()