예제 #1
0
 def onPlayBackStopped(self):
     addon_log('STOP')
     #xbmc.executebuiltin('Container.Refresh()')
     try:
         stop_spsc(self.spsc_pid)
     except:
         pass
     addon.setSetting('player_status', 'stop')
예제 #2
0
 def onPlayBackStopped(self):
   addon_log('STOP')
   #xbmc.executebuiltin('Container.Refresh()')
   try: stop_spsc(self.spsc_pid)
   except: pass
   addon.setSetting('player_status', 'stop')
예제 #3
0
def STREAM(name, iconimage, url, sch_ch_id):
    if (url == None):
        try:
            xbmc.executebuiltin("Dialog.Close(all,true)")
        except:
            pass
        return False

    if (sch_ch_id != None) and (DISABLE_SCHEDULE != 'true'):
        grab_schedule(sch_ch_id, name)

    #addon_log(name)
    #addon_log(iconimage)

    if not iconimage or iconimage == "": iconimage = "DefaultVideo.png"
    listitem = xbmcgui.ListItem(name,
                                iconImage="DefaultVideo.png",
                                thumbnailImage=iconimage)
    listitem.setLabel(name)
    listitem.setInfo('video', {'Title': name})

    if url[0:6] == "sop://":  #play sopcast stream
        try:
            cmd = [
                SPSC, url,
                str(LOCAL_PORT),
                str(VIDEO_PORT), "> /dev/null &"
            ]
            if (ARM):
                cmd = QEMU_SPSC + cmd
            #addon_log(cmd)
            spsc = subprocess.Popen(cmd,
                                    shell=False,
                                    bufsize=BUFER_SIZE,
                                    stdin=None,
                                    stdout=None,
                                    stderr=None)

            xbmc.sleep(int(addon.getSetting('wait_time')))

            res = False
            counter = 50
            #while counter > 0 and os.path.exists("/proc/"+str(spsc.pid)):
            while counter > 0 and sop_pid_exists(spsc.pid):
                xbmc.executebuiltin("ActivateWindow(busydialog)")
                xbmc.sleep(400)
                counter -= 1
                try:
                    addon_log(LOCAL_URL)
                    urllib2.urlopen(LOCAL_URL)
                    counter = 0
                    res = sop_sleep(200, spsc.pid)
                    break
                except:
                    pass

            addon_log(res)

            if res:
                player = streamplayer(xbmc.PLAYER_CORE_AUTO,
                                      spsc_pid=spsc.pid,
                                      name=name)
                addon.setSetting('player_status', 'play')
                player.play(LOCAL_URL, listitem)

                keep_allive(player)

                #watching sop process and restarting the player if it dies
                #watch_sop_thread(spsc.pid, name, listitem)

            #elif not os.path.exists("/proc/"+str(spsc.pid)):
            elif not sop_pid_exists(spsc.pid):
                try:
                    xbmc.executebuiltin("Dialog.Close(all,true)")
                except:
                    pass
                try:
                    urllib2.urlopen("http://www.google.com")
                    if NOTIFY_OFFLINE == "true":
                        xbmc.executebuiltin("Notification(%s,%s,%i)" %
                                            (addon.getLocalizedString(30057),
                                             "", 1))  #Channel is offline
                except:
                    if NOTIFY_OFFLINE == "true":
                        xbmc.executebuiltin("Notification(%s,%s,%i)" %
                                            (addon.getLocalizedString(30058),
                                             "", 1))  #Network is offline
            elif NOTIFY_OFFLINE == "true":
                try:
                    xbmc.executebuiltin("Dialog.Close(all,true)")
                except:
                    pass
                xbmc.executebuiltin("Notification(%s,%s,%i)" %
                                    (addon.getLocalizedString(30059), "",
                                     1))  #Channel initialization failed
                try:
                    stop_spsc(spsc.pid)
                except:
                    pass

        except Exception as inst:
            xbmcgui.Dialog().ok(addon.getLocalizedString(30060),
                                str(type(inst)), str(inst), "")
            addon_log(str(inst))
            try:
                stop_spsc()
            except:
                pass
            try:
                xbmc.executebuiltin("Dialog.Close(all,true)")
            except:
                pass

    else:  #play direct stream
        try:
            player = streamplayer(xbmc.PLAYER_CORE_AUTO, name=name)
            addon.setSetting('player_status', 'play')
            player.play(url, listitem)
            keep_allive(player)

        except Exception as inst:
            xbmcgui.Dialog().ok(addon.getLocalizedString(30060),
                                str(type(inst)), str(inst), "")
            try:
                xbmc.executebuiltin("Dialog.Close(all,true)")
            except:
                pass
예제 #4
0
def STREAM(name, iconimage, url, sch_ch_id):
  if(url == None):
    try: xbmc.executebuiltin("Dialog.Close(all,true)")
    except: pass
    return False
  
  if (sch_ch_id != None) and (DISABLE_SCHEDULE != 'true'):
    grab_schedule(sch_ch_id, name)
    
  #addon_log(name)
  #addon_log(iconimage)
  
  if not iconimage or iconimage == "": iconimage="DefaultVideo.png"
  listitem = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
  listitem.setLabel(name)
  listitem.setInfo('video', {'Title': name})
  
  if url[0:6]=="sop://": #play sopcast stream
    try:
      cmd = [SPSC, url, str(LOCAL_PORT), str(VIDEO_PORT), "> /dev/null &"]
      if(ARM):
        cmd = QEMU_SPSC + cmd
      #addon_log(cmd)
      spsc = subprocess.Popen(cmd, shell=False, bufsize=BUFER_SIZE, stdin=None, stdout=None, stderr=None)
      
      xbmc.sleep(int(addon.getSetting('wait_time')))
      
      res=False
      counter=50
      #while counter > 0 and os.path.exists("/proc/"+str(spsc.pid)):
      while counter > 0 and sop_pid_exists(spsc.pid):
        xbmc.executebuiltin( "ActivateWindow(busydialog)" )
        xbmc.sleep(400)
        counter -= 1
        try:
          addon_log(LOCAL_URL);
          urllib2.urlopen(LOCAL_URL)
          counter=0
          res=sop_sleep(200 , spsc.pid)
          break
        except:pass
      
      addon_log(res)
        
      if res:
        player = streamplayer(xbmc.PLAYER_CORE_AUTO , spsc_pid=spsc.pid, name=name)
        addon.setSetting('player_status', 'play')
        player.play(LOCAL_URL, listitem)
        
        keep_allive(player)
        
        #watching sop process and restarting the player if it dies
        #watch_sop_thread(spsc.pid, name, listitem)
        
      #elif not os.path.exists("/proc/"+str(spsc.pid)):
      elif not sop_pid_exists(spsc.pid):
        try: xbmc.executebuiltin("Dialog.Close(all,true)")
        except: pass
        try:
          urllib2.urlopen("http://www.google.com")
          if NOTIFY_OFFLINE == "true": xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30057), "",1))  #Channel is offline
        except:
          if NOTIFY_OFFLINE == "true": xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30058), "",1)) #Network is offline
      elif NOTIFY_OFFLINE == "true": 
        try: xbmc.executebuiltin("Dialog.Close(all,true)")
        except: pass
        xbmc.executebuiltin("Notification(%s,%s,%i)" % (addon.getLocalizedString(30059), "", 1)) #Channel initialization failed
        try: stop_spsc(spsc.pid)
        except: pass
    
    except Exception as inst:
      xbmcgui.Dialog().ok(addon.getLocalizedString(30060), str(type(inst)),str(inst),"")
      addon_log(str(inst))
      try:
        stop_spsc()
      except: pass
      try: xbmc.executebuiltin("Dialog.Close(all,true)")
      except: pass
      
  else: #play direct stream
    try:
      player = streamplayer(xbmc.PLAYER_CORE_AUTO, name=name)
      addon.setSetting('player_status', 'play')
      player.play(url, listitem)
      keep_allive(player)
      
    except Exception as inst:
      xbmcgui.Dialog().ok(addon.getLocalizedString(30060), str(type(inst)),str(inst),"")
      try: xbmc.executebuiltin("Dialog.Close(all,true)")
      except: pass