2014-07-03, 00:43
Hi
I can't figure this out maybe some can help me
This is the code i am using do download a file
It's downloads the file just fine, but i can't play the file right after download, i can if restart xbmc or use the file manger to play the file
this is the function i am using to play the file
this is the debug log
thank's
I can't figure this out maybe some can help me
This is the code i am using do download a file
PHP Code:
def descarregar_ficheiro_video(url, nome_ficheiro):
global home_video_folder
log ("descarregar_ficheiro_video: " + url + ", " + nome_ficheiro)
if not os.path.isfile(os.path.join( home_video_folder , nome_ficheiro)):
log ("O ficheiro ainda nao existe: " + nome_ficheiro)
nome_ficheiro=None
else:
nome_ficheiro=os.path.join( home_video_folder , nome_ficheiro)
log ("O ficheiro ja existe: " + nome_ficheiro)
log("A descarregar ficheiro de: " + url )
ficheiro_temp= os.path.join(home_video_folder, "temp.mp4")
if os.path.exists(ficheiro_temp):
try:
log("O ficheiro temporario ja existe, a remover" )
os.remove(ficheiro_temp)
log("O ficheiro temporario foi removido" )
except:
log("Nao foi possivel remover o ficheiro temporario, return" + ficheiro )
return nome_ficheiro
try:
log("A abrir o URL:" + url )
f = urlopen(url)
ficheiro = re.findall("filename=\"(\S+)\"", f.info().getheader('Content-Disposition'))
ficheiro = ficheiro[0]
ficheiro = os.path.join( home_video_folder , ficheiro)
log("Nome do ficheiro a descarregar: " + ficheiro )
if os.path.isfile(ficheiro):
log("O ficheiro ja existe: " + ficheiro )
statinfo = os.stat(ficheiro)
log("O ficheiro tem o seguinte tamanho: " + str(statinfo.st_size) )
if statinfo.st_size==0:
log("O ficheiro esta vazio, vamos remover:" + ficheiro )
try:
os.remove(ficheiro)
log("O ficheiro foi removido" + ficheiro )
except:
log("Nao consegui remover o ficheiro, return" + ficheiro )
return nome_ficheiro
try:
log("A descarregar " + ficheiro + " para: " + ficheiro_temp)
with open(ficheiro_temp, 'wb') as outfile:
outfile.write(f.read())
log("O ficheiro foi decarregado com sucesso " + ficheiro_temp )
outfile.close
f.close
log("ficheiro e ligacao foram fechados" )
except:
log("Ocorreu um erro ao descarregar" + ficheiro_temp )
try:
log("A mudar o nome do ficheiro temporario para: " + ficheiro)
os.rename(ficheiro_temp, ficheiro)
nome_ficheiro= ficheiro
except:
log("Nao consegui mudar o nome do ficheiro, return " + ficheiro)
return nome_ficheiro
except HTTPError, e:
print "HTTP Error:", e.code, url
except URLError, e:
print "URL Error:", e.reason, url
except:
log("Ocorreu um erro desconhecido" )
return nome_ficheiro[code]
It's downloads the file just fine, but i can't play the file right after download, i can if restart xbmc or use the file manger to play the file
this is the function i am using to play the file
PHP Code:
def reproduz_ficheiro(ficheiro):
log("A reproduzir fallback")
xbmc.executebuiltin('xbmc.PlayerControl("RepeatAll", "Notify")')
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
playlist.clear()
playlist.add(ficheiro)
xbmc.Player().play(playlist)
this is the debug log
Code:
23:42:01 T:3036611360 NOTICE: COMXPlayer: Opening: /home/pi/wedoiptv/931D670C-9CF3-4A4A-9E4C-974F9630BE02.mp4
23:42:01 T:3036611360 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
23:42:01 T:2785014848 NOTICE: Thread OMXPlayer start, auto delete: false
23:42:01 T:2785014848 NOTICE: Creating InputStream
23:42:01 T:2785014848 ERROR: COMXPlayer::OpenInputStream - error opening [/home/pi/wedoiptv/931D670C-9CF3-4A4A-9E4C-974F9630BE02.mp4]
23:42:01 T:2785014848 NOTICE: COMXPlayer::OnExit()
23:42:01 T:2785014848 NOTICE: COMXPlayer::OnExit() deleting input stream
23:42:01 T:3036611360 ERROR: XBMC.PlayMedia could not play media: /home/pi/wedoiptv/931D670C-9CF3-4A4A-9E4C-974F9630BE02.mp4
23:42:01 T:3036611360 NOTICE: COMXPlayer: finished waiting
[/quote]
thank's