Using libVLC media_list instead of a media_player to play a directory of songs

后端 未结 1 830
臣服心动
臣服心动 2021-01-28 06:13

I\'m trying to use libVLC v2 C bindings in order to play all the songs (mp3/m4a/ogg)s inside a directory given i

相关标签:
1条回答
  • 2021-01-28 06:45

    media_list is used to play play lists(.pls .m3u etc) as opposed to individual files.
    Not sure about c but in python:

    Media_list = Instance.media_list_new([url])
    list_player = Instance.media_list_player_new()
    list_player.set_media_list(Media_list)
    list_player.play()
    

    as opposed to:

    player = Instance.media_player_new()
    Media = Instance.media_new(url)
    Media.get_mrl()
    player.set_media(Media)
    player.play()
    

    for an individual file.
    I hope that you can pick the bones out of the above.
    For your purposes, it looks like you need to use the individual file option, using a url list, whilst looping over the list.

    Again (apologies) in python:

    import vlc
    import time
    my_list = ['vp1.mp3','happy.mp3']
    instance = vlc.Instance()
    player = instance.media_player_new()
    playing = set([1,2,3,4])
    for i in my_list:
        player.set_mrl(i)
        player.play()
        play=True
        while play == True:
            time.sleep(1)
            play_state = player.get_state()
            if play_state in playing:
                continue
            else:
                play = False
    
    0 讨论(0)
提交回复
热议问题