oneplay

mail@pastecode.io avatar
unknown
python
2 years ago
2.1 kB
4
Indexable
Never
def start_dlna(url):
    #try:
    infoDialog('Procurando dispositivo!', iconimage='INFO', time=200)
    from libs.dlna import PlayOn
    from libs.server import mediaserver
    DLNARendererControllerInstance = PlayOn.DLNAController()
    DLNARendererControllerInstance.discover(timeout=5)
    mylist = [(r, renderer) for r, renderer in enumerate(DLNARendererControllerInstance.Renderers) if renderer.StatusAlive and bool(renderer.BaseURL)]
    if mylist:
        options = []
        for r, render in mylist:
            name = render.FriendlyName
            options.append((name,r))
        if options:
            items_options = [name for name, r in options]
            try:
                op = select_op(name='SELECIONE UM DISPOSITIVO:',items=items_options)
                name = options[op][0]
                r = options[op][1]
            except:
                name = False
                r = False
            if name:
                renderer = DLNARendererControllerInstance.Renderers[r]
                kind = 'video'
                size = ''
                duration = ''
                title = 'ONEPLAY'
                uri = url
                mediaserver().start()
                time.sleep(3)
                infoDialog('Aguarde...', iconimage='INFO', time=10)
                DLNARendererControllerInstance.send_URI(renderer, uri, title, kind, size, duration)
                DLNARendererControllerInstance.send_Play(renderer)                        
                q = question_dlna()
                if q:
                    DLNARendererControllerInstance.send_Stop(renderer)
                    mediaserver().stop()
                    dialog.ok('Oneplay', 'servidor encerrado!')
            else:
                infoDialog('Falha ao selecionar!', iconimage='INFO', time=10)
        else:
            infoDialog('Nenhum dispositivo!', iconimage='INFO', time=10)
    else:
        infoDialog('Nenhum dispositivo!', iconimage='INFO', time=10)
    #except:
    #    infoDialog(message='Falha ao espelhar!', iconimage='INFO')