Как выбрать заголовок / дорожку аудио из плейлиста аудио компакт-диска с vl c in Python - PullRequest
0 голосов
/ 29 мая 2020

Я не могу найти способ выбрать трек из созданного списка воспроизведения. Чтобы проиллюстрировать мою проблему, я создал простой GUI. Загрузите лоток для компакт-диска с аудио-компакт-диском и нажмите кнопку «Воспроизвести список треков» Я могу воспроизвести весь список воспроизведения.

Но когда я пытаюсь выбрать трек (нажатие на кнопку 'Play Track ID' ) Я получаю следующее сообщение об ошибке:

    '''This results the following error message:
     File "D:/Python-Programme/gui-beispiel/CD-Project/question.py", line 46, in play_id_of_medialist
            instance.playlist_play(7, 0)
            TypeError: playlist_play() missing 1 required positional argument: 'ppsz_options'''

Я не понял свою ошибку. Я установил ноль (0) для параметров, но был запрошен 'ppsz_options' . Очевидно, я неправильно понял функцию 'playlist_play' , но я не знал, в чем моя ошибка.

from http://www.olivieraubert.net/vlc/python-ctypes/doc/
playlist_play(self, i_id, i_options, ppsz_options)
Start playing (if there is any item in the playlist).
Additional playlist item options can be specified for addition to the item before it is played.

Parameters:
i_id            - the item to play. If this is a negative number,
                  the next item will be selected. Otherwise,
                  the item with the given ID will be played.
i_options       - the number of options to add to the item.
ppsz_options    - the options to add to the item.

Надеюсь, эксперт по vl c сможет дайте мне полезный совет.

import vlc
from tkinter import *

root = Tk()

cd_lw = 'cdda:///E:/'
instance = vlc.Instance('--quiet')

listplayer = instance.media_list_player_new()
medialist = instance.media_list_new()
songs = instance.media_new(cd_lw)
medialist.add_media(songs)
listplayer.set_media_list(medialist)


def play_the_list():
    listplayer.play()


def good_bye():
    listplayer.stop()
    exit()


def play_id_of_medialist():
    instance.playlist_play(7, 0)


play_all = Button(root, text='Play Track List', command=play_the_list).pack()
play_id = Button(root, text='Play Track ID', command=play_id_of_medialist).pack()
ended_all = Button(root, text='Exit', command=good_bye).pack()

root.mainloop()
...