May-03-2018, 12:38 AM
Hi all,
I need your help. I am working on play function to fetch the video links in the database so I can play the video. I have got a bit of trouble with looping the code, because when I find the video link is dead I want to skip and fetch the video link in the next column until I find the working video link to play the video.
Here is the code:
I have got 3 columns in the database
Can you please show me an example what I should write in a proper way without crash the application?
Thanks in advance.
I need your help. I am working on play function to fetch the video links in the database so I can play the video. I have got a bit of trouble with looping the code, because when I find the video link is dead I want to skip and fetch the video link in the next column until I find the working video link to play the video.
Here is the code:
def play(self, item = None, windowed = False): print "you are working on play.........................." bool = True url = '' if not self.player.isPlayingVideo(): conn = database.connect(self.profilePath + 'source.db') cur = conn.cursor() self.count += 1 print "self.count...............................for stream_url column" print self.count try: cur.execute('SELECT stream' + str(self.count) + '_url FROM streams WHERE channels=?', [self.EPG_Channel]) data = cur.fetchone() if data is not None: url = data[0] except: self.count = 1 cur.execute('SELECT stream1_url FROM streams WHERE channels=?', [self.EPG_Channel]) data = cur.fetchone() if data is not None: url = data[0] conn.close() self.player.play(url, windowed = bool) self.channel_pressed = False if not self.player.isPlayingVideo(): self.play()On my code that I wrote, it will keep looping and firing the code to fetch the link from the column
stream1_url
as it will not skip to the next column as it will make the application to get crash.I have got 3 columns in the database
stream1_url
, stream2_url
and stream3_url
in a database. What I am trying to do is I want to fetch the video link from the column stream1_url
and play the video. If the video don't start to play as the link is dead, I want to call the play function again when I am using self.count += 1
to count it to up so I can fetch the new video link from the column stream2_url
, but it the link is not working I want to call the play function again and fetch the video link from the column stream3_url
and play the video.Can you please show me an example what I should write in a proper way without crash the application?
Thanks in advance.