Bsplayer is a videoplayer. I want to start bsplayer with the parameter -stime-x, where x is the amount of seconds. This result in playing a movie from say 23 minutes 10 seconds with the parameter -stime=1390. The whole thing I can manage to do in DOS and looks like:

@echo off
"c:\program files\webteh\bsplayerpro\bsplayer.exe" "D:\rodin\rodin.mp4" -stime=1390
but whatever I try and search for on this forum and google of course

I cannot settle this in python code. I want to hop to a interesting time positions in the vid with a menu. What i have is this:


import webbrowser
import os
import win32api

print 'Marko Rodin\n'
print 'what starting time? '
a=raw_input('hour:')
b=raw_input('minutes, ')
c=raw_input('seconds ')
d=(int(a)*3600)+int(b)+int(c)
  
#win32api.ShellExecute(0,"open", "Vortex Based Mathematics by Marko Rodin.mp4","-stime=1390","D:\\rodin",1) DOESNOT WORK
os.execve("c:\\program files\\webteh\\bsplayerpro\\bsplayer.exe", ["-stime=str(d)"], "d:\\rodin\\rodin.mp4") # TypeError: execve() arg 3 must be a mapping object

What's wrong with this and is there another shorter way to start the vid in this manner?
Thanks!

The str(d) in the argument doesn't work. I suggest that you use the subprocess module

import subprocess as SP
SP.Popen(["c:\\program files\\webteh\\bsplayerpro\\bsplayer.exe", "-stime="+str(d), "d:\\rodin\\rodin.mp4"])

Thanks for the quick reply. I have used the popen command and it works, but alas, not with the parameter. It just starts plain bsplayer.

import webbrowser
import os
import win32api
import subprocess as SP


print 'Marko Rodin\n'
print 'what starting time? '
a=raw_input('hour:')
b=raw_input('minutes, ')
c=raw_input('seconds ')

h=int(a)*3600
d=h+int(b)+int(c)
SP.Popen(["c:\\program files\\webteh\\bsplayerpro\\bsplayer.exe", "-stime="+str(d), "d:\\rodin\\rodin.mp4"])

This may work

SP.Popen("c:\\program files\\webteh\\bsplayerpro\\bsplayer.exe d:\\rodin\\rodin.mp4 -stime"+str(d), shell=True)

Shows up only the plain bsplayer. I have looked in the book of Hammond about win32 programming with python. What I miss is a whole lot of concrete down to the earth examples. There seem to be twenty or so sort a like commands with a variety of parameters.
Thanks though for your help :)

Also I have tried a totally different approach, need I say, again not working...

import os, sys
print 'Marko Rodin\n'
print 'what starting time? '
a=raw_input('hour:')
b=raw_input('minutes, ')
c=raw_input('seconds ')

h=int(a)*3600
d=h+int(b)+int(c)

z1="@echo off\n"
z2="c:\\program files\\webteh\\bsplayerpro\\bsplayer.exe"
z3=" "
z4="D:\\rodin\\rodin.mp4"
z5="-stime="
z6=str(d)
z=z1+z2+z3+z4+z5+z6

f=open(r"c:\python26\\HOME\rodin.bat",'w')


f.write(z)
f.close
os.execvp("c:\\python26\\HOME\\\rodin.bat",[' '])

This may work

SP.Popen("c:\\program files\\webteh\\bsplayerpro\\bsplayer.exe d:\\rodin\\rodin.mp4 -stime"+str(d), shell=True)


# I have allways been a searcher for truth, but now descended into the dungeons of python,
# wanting a code for a pregiven movie to start at a certain time,
# not specially with a dos batch file, but that turned out the only way to succeed, for me 

import os
print 'Marko Rodin movie "Vortex Based Mathematics"'
print 'what time do you want to start the movie?'
h=raw_input('hour:       ')
m=raw_input('minutes:   ')
s=raw_input('seconds:   ')

hours=int(h)*3600
minutes=int(m)*60
seconds=int(s)

#the parameter has the format -stime=xxx where xxx is the amount of seconds, i.e. the time from where the movie will start
parameter1a="-stime="
parameter1b=hours+minutes+seconds
parameter=str(parameter1a)+str(parameter1b)

#these will be the contents of the dos batch file, c.q. rodin.bat
text1="@echo off\n"
text2='"c:\program files\\webteh\\bsplayerpro\\bsplayer.exe"'
text3=' "D:\\rodin\\rodin.mp4" '
text4=parameter

#to glue all together
all=[]
text=text1+text2+text3+text4
all.append(text)
f = open("rodin.bat", 'w')
f.write('\n'.join(all))
f.close()


os.system("rodin.bat")

.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.