示例#1
0
def SelectItem(mediaitem=CMediaItem()):
    type = mediaitem.GetType()
    if type == 'playlist' or type == 'favorite' or type[0:3] == 'rss' or \
       type == 'rss_flickr_daily' or type == 'directory' or \
       type == 'html_youtube' or type == 'xml_shoutcast' or \
       type == 'xml_applemovie':
           
            result = ParsePlaylist(mediaitem)           

    elif type == 'video' or type == 'audio' or type == 'html':
        MyPlayer = CPlayer(xbmc.PLAYER_CORE_AUTO, function=myPlayerChanged)
        result = MyPlayer.play_URL(mediaitem.URL, mediaitem)       
            
        if result != 0:
            dialog = xbmcgui.Dialog()
            dialog.ok("Error", "Could not open file.")
                      
    elif type == 'image':
        viewImage(mediaitem.URL) #single file show
    elif type == 'text':
        OpenTextFile(mediaitem=mediaitem)
    elif type[0:6] == 'script' or type[0:6] == 'plugin':
        InstallApp(mediaitem=mediaitem)
    elif type == 'download':
        Download(mediaitem.URL)
    elif (type[0:6] == 'search'):
        PlaylistSearch(mediaitem, True)
    else:
        dialog = xbmcgui.Dialog()
        dialog.ok("Playlist format error", '"' + type + '"' + " is not a valid type.")
示例#2
0
def SelectItem(mediaitem=CMediaItem()):
    type = mediaitem.GetType()
    if type == 'playlist' or type == 'favorite' or type[0:3] == 'rss' or \
       type == 'rss_flickr_daily' or type == 'directory' or \
       type == 'html_youtube' or type == 'xml_shoutcast' or \
       type == 'xml_applemovie':

        result = ParsePlaylist(mediaitem)

    elif type == 'video' or type == 'audio' or type == 'html':
        MyPlayer = CPlayer(xbmc.PLAYER_CORE_AUTO, function=myPlayerChanged)
        result = MyPlayer.play_URL(mediaitem.URL, mediaitem)

        if result != 0:
            dialog = xbmcgui.Dialog()
            dialog.ok("Error", "Could not open file.")

    elif type == 'image':
        viewImage(mediaitem.URL)  #single file show
    elif type == 'text':
        OpenTextFile(mediaitem=mediaitem)
    elif type[0:6] == 'script' or type[0:6] == 'plugin':
        InstallApp(mediaitem=mediaitem)
    elif type == 'download':
        Download(mediaitem.URL)
    elif (type[0:6] == 'search'):
        PlaylistSearch(mediaitem, True)
    else:
        dialog = xbmcgui.Dialog()
        dialog.ok("Playlist format error",
                  '"' + type + '"' + " is not a valid type.")
示例#3
0
def SelectItem(mediaitem=CMediaItem()):
    type = mediaitem.type
    if type == 'playlist' or type == 'favorite' or type[0:3] == 'rss' or \
       type == 'rss_flickr_daily' or type == 'directory' or \
       type == 'html_youtube' or type == 'xml_shoutcast' or \
       type == 'xml_applemovie':
                if 'special://' in mediaitem.URL:
                        mediaitem.URL = xbmc.translatePath(mediaitem.URL)
                result = ParsePlaylist(mediaitem)             

    elif type == 'video' or type == 'audio' or type == 'html':
#these lines are used for debugging only
#                self.onDownload()
#                self.state_busy = 0
#                self.selectBoxMainList()
#                self.state_busy = 0                
#                return
                
#       if (playlist != 0) and (playlist.playmode == 'autonext'):
#            size = playlist.size()
#            if playlist.player == 'mplayer':
#                MyPlayer = CPlayer(xbmc.PLAYER_CORE_MPLAYER, function=myPlayerChanged)
#            elif playlist.player == 'dvdplayer':
#                MyPlayer = CPlayer(xbmc.PLAYER_CORE_DVDPLAYER, function=myPlayerChanged)
#            else:
#                MyPlayer = CPlayer(xbmc.PLAYER_CORE_AUTO, function=.myPlayerChanged)                
#            result = MyPlayer.play(playlist, pos, size-1)
#        else:
        if(True):
#            xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play(mediaitem.URL)
#            if mediaitem.player == 'mplayer':
#                MyPlayer = CPlayer(xbmc.PLAYER_CORE_MPLAYER, function=myPlayerChanged)
#            elif mediaitem.player == 'dvdplayer':
#                MyPlayer = CPlayer(xbmc.PLAYER_CORE_DVDPLAYER, function=myPlayerChanged)
#            else:
                MyPlayer = CPlayer(xbmc.PLAYER_CORE_AUTO, function=myPlayerChanged)
                result = MyPlayer.play_URL(mediaitem.URL, mediaitem)      
#            dialog.close()   
            
                if result != 0:
                    dialog = xbmcgui.Dialog()
                    dialog.ok("Error", "Could not open file.")
                
    elif type == 'image':
        viewImage(mediaitem.URL) #single file show
    elif type == 'text':
        OpenTextFile(mediaitem=mediaitem)
    elif type == 'window':
        xbmc.executebuiltin("xbmc.ActivateWindow(" + mediaitem.URL + ",Root)")             
    elif type[0:6] == 'script' or type[0:6] == 'plugin':
        InstallApp(mediaitem=mediaitem)
#            elif type == 'download':
#                self.onDownload()
    elif (type[0:6] == 'search'):
        PlaylistSearch(mediaitem, True)
    else:
        dialog = xbmcgui.Dialog()
        dialog.ok("Playlist format error", '"' + type + '"' + " is not a valid type.")
async def handler(requests):
    global get_dict
    ws = web.WebSocketResponse()
    if not get_dict:
        global dic
        dic = requests.app
        get_dict = True
    print('a user connected')
    await ws.prepare(requests)
    # add player into it
    cur_player = CPlayer.Player(ws)
    requests.app['Players'].append(cur_player)
    try:
        async for msg in ws:
            # print('recv {}'.format(msg.data))
            if msg.type == aiohttp.WSMsgType.TEXT:
                if msg.data == b'close':
                    break
                await message_dispatcher(msg.data, requests, cur_player)
    finally:
        await cur_player.purge()
        requests.app['Players'].remove(cur_player)
    print(cur_player, 'log out')
    return ws
示例#5
0
def SelectItem(iURL='', listitem=''):
    if listitem != '':
        mediaitem=CMediaItem()
        mediaitem.URL = listitem.GetProperty("url")
        mediaitem.processor = listitem.GetProperty("processor")
        mediaitem.type = listitem.GetProperty("media_type")
        mediaitem.background = listitem.GetProperty("background")
    elif iURL != '':
        mediaitem=CMediaItem()
        mediaitem.URL = iURL
        ext = getFileExtension(iURL)
        if ext == 'plx':
            mediaitem.type = 'playlist'
        elif ext == 'xml' or ext == 'atom':
            mediaitem.type = 'rss'        
        elif ext == 'jpg' or ext == 'png' or ext == 'gif':
            mediaitem.type = 'image'
        elif ext == 'txt':
            mediaitem.type == 'text'
        elif ext == 'zip':
            mediaitem.type == 'script'
        else:
            mediaitem.type = 'video' #same as audio
    else:
        if playlist.size() == 0:
            #playlist is empty
            return
       
        mediaitem = playlist.list[pos]
    
    #type = mediaitem.type
    type = mediaitem.GetType()

    #mediaitem is some type of playlist (non-search, non-media)
    
    if type == 'playlist' or type == 'favorite' or type[0:3] == 'rss' or \
       type == 'rss_flickr_daily' or type == 'directory' or \
       type == 'html_youtube' or type == 'xml_shoutcast' or \
       type == 'xml_applemovie' or type == 'atom' or type == 'opml':
        #add new URL to the history array
        mc.GetWindow(14000).PushState()

        #exception case: Do not add Youtube pages to history list
#        if mediaitem.GetType() == 'html_youtube':
#            append = False
                
        result = ParsePlaylist(mediaitem=mediaitem)
        ##mc.ShowDialogOk("Debug", "ParsePlaylist result = " + str(result))
        
        if result != 0:        ### ParsePlaylist failed + playlist cleared by ParsePlaylist
            mc.HideDialogWait()
            return -1      

    #mediaitem is a audio or video to play

    elif type == 'video' or type == 'audio' or type == 'html':
        mc.ShowDialogWait()
        MyPlayer = CPlayer()

        ##mc.ShowDialogOk("Debug in SelectItem", "type = " + mediaitem.type + '\n' + "processor = " + mediaitem.processor)

        result = MyPlayer.play_URL(mediaitem.URL, mediaitem)
                                                
        mc.HideDialogWait()

        if result["code"] == 1:
            # general error
            try:
                result["data"]
            except KeyError:
                result["data"]="Cannot open file"
            
            if result["data"][0:2] == 'p:':
                result["data"]=result["data"][2:]
                etitle="Processor Error"
            else:
                etitle="Error"
            mc.ShowDialogOk(etitle, result["data"])

        elif result["code"] == 2:
            # redirect to playlist
            redir_item=CMediaItem()
            redir_item.URL=result["data"]
            redir_item.type='playlist'
            ParsePlaylist(mediaitem=redir_item, URL=result["data"])

        else:
            #When app reloads after play it will resume at the last playlist viewed 
            mc.GetApp().GetLocalConfig().SetValue("resume", "True")

    #mediaitem is other type: go through possibilites

    elif type == 'image':
        viewImage(0,mediaitem) #single file show
        mc.GetApp().GetLocalConfig().SetValue("resume", "True")        


    elif type == 'text':
        mc.GetWindow(14000).PushState()
        OpenTextFile(mediaitem=mediaitem)

    elif (type[0:3] == 'app'):
        InstallApp(mediaitem=mediaitem)

    elif type == 'download':
        mc.ShowDialogOk("Error", "This item is not supported because it is a " + type)

    elif (type[0:6] == 'search'):
        mediaitem_search = PlaylistSearch(mediaitem)
        if mediaitem_search != None:
            mc.GetWindow(14000).PushState()
            result = ParsePlaylist(mediaitem=mediaitem_search)
        
    elif type == 'window':
        mc.ShowDialogOk("Error", "This item is not supported because it is a " + type)

    else:
        mc.ShowDialogOk("Playlist format error", '"' + type + '"' + " is not a valid type.")
        
    return 0
示例#6
0
def SelectItem(iURL='', listitem=''):
    if listitem != '':
        mediaitem = CMediaItem()
        mediaitem.URL = listitem.GetProperty("url")
        mediaitem.processor = listitem.GetProperty("processor")
        mediaitem.type = listitem.GetProperty("media_type")
        mediaitem.background = listitem.GetProperty("background")
    elif iURL != '':
        mediaitem = CMediaItem()
        mediaitem.URL = iURL
        ext = getFileExtension(iURL)
        if ext == 'plx':
            mediaitem.type = 'playlist'
        elif ext == 'xml' or ext == 'atom':
            mediaitem.type = 'rss'
        elif ext == 'jpg' or ext == 'png' or ext == 'gif':
            mediaitem.type = 'image'
        elif ext == 'txt':
            mediaitem.type == 'text'
        elif ext == 'zip':
            mediaitem.type == 'script'
        else:
            mediaitem.type = 'video'  #same as audio
    else:
        if playlist.size() == 0:
            #playlist is empty
            return

        mediaitem = playlist.list[pos]

    #type = mediaitem.type
    type = mediaitem.GetType()

    #mediaitem is some type of playlist (non-search, non-media)

    if type == 'playlist' or type == 'favorite' or type[0:3] == 'rss' or \
       type == 'rss_flickr_daily' or type == 'directory' or \
       type == 'html_youtube' or type == 'xml_shoutcast' or \
       type == 'xml_applemovie' or type == 'atom' or type == 'opml':
        #add new URL to the history array
        mc.GetWindow(14000).PushState()

        #exception case: Do not add Youtube pages to history list
        #        if mediaitem.GetType() == 'html_youtube':
        #            append = False

        result = ParsePlaylist(mediaitem=mediaitem)
        ##mc.ShowDialogOk("Debug", "ParsePlaylist result = " + str(result))

        if result != 0:  ### ParsePlaylist failed + playlist cleared by ParsePlaylist
            mc.HideDialogWait()
            return -1

    #mediaitem is a audio or video to play

    elif type == 'video' or type == 'audio' or type == 'html':
        mc.ShowDialogWait()
        MyPlayer = CPlayer()

        ##mc.ShowDialogOk("Debug in SelectItem", "type = " + mediaitem.type + '\n' + "processor = " + mediaitem.processor)

        result = MyPlayer.play_URL(mediaitem.URL, mediaitem)

        mc.HideDialogWait()

        if result["code"] == 1:
            # general error
            try:
                result["data"]
            except KeyError:
                result["data"] = "Cannot open file"

            if result["data"][0:2] == 'p:':
                result["data"] = result["data"][2:]
                etitle = "Processor Error"
            else:
                etitle = "Error"
            mc.ShowDialogOk(etitle, result["data"])

        elif result["code"] == 2:
            # redirect to playlist
            redir_item = CMediaItem()
            redir_item.URL = result["data"]
            redir_item.type = 'playlist'
            ParsePlaylist(mediaitem=redir_item, URL=result["data"])

        else:
            #When app reloads after play it will resume at the last playlist viewed
            mc.GetApp().GetLocalConfig().SetValue("resume", "True")

    #mediaitem is other type: go through possibilites

    elif type == 'image':
        viewImage(0, mediaitem)  #single file show
        mc.GetApp().GetLocalConfig().SetValue("resume", "True")

    elif type == 'text':
        mc.GetWindow(14000).PushState()
        OpenTextFile(mediaitem=mediaitem)

    elif (type[0:3] == 'app'):
        InstallApp(mediaitem=mediaitem)

    elif type == 'download':
        mc.ShowDialogOk("Error",
                        "This item is not supported because it is a " + type)

    elif (type[0:6] == 'search'):
        mediaitem_search = PlaylistSearch(mediaitem)
        if mediaitem_search != None:
            mc.GetWindow(14000).PushState()
            result = ParsePlaylist(mediaitem=mediaitem_search)

    elif type == 'window':
        mc.ShowDialogOk("Error",
                        "This item is not supported because it is a " + type)

    else:
        mc.ShowDialogOk("Playlist format error",
                        '"' + type + '"' + " is not a valid type.")

    return 0