Open wilderlopes83 opened 5 years ago
After adding some delay (there are other**, better ways to do this)
p.play()
time.sleep(5)
the media.get_meta
call did return several non-None
values, but only when music is playing:
[00007f9bda80f9c0] mpeg4audio demux packetizer: AAC channels: 1 samplerate: 22050
0 -
1 - None
2 - Adult Contemporary
...
12 - Jimmy Cliff - I can see clearly now
Btw, this is with VLC 3.0.4 on macOS 10.13.6.
**) See Olivier's comment for issue #71.
Hi mrJean1. Thanks for your answer. I think the problem is that despite media.parse() is a syncronous method, the streaming wasn't loaded when I tried to check song information. I put and time.sleep(5) after parse in order to check if streaming status is already playing and it worked fine. I had not to comment media.get_mrl(). Regards
The explore the parsing of media meta data, following are some other observations:
from time import sleep
from vlc import EventType, Media, MediaPlayer, MediaParseFlag, Meta
def _media_cb(event, *unused):
# XXX callback ... never called
print(event)
p = MediaPlayer()
# cmd1 = "sout=file/ts:%s" % outfile
media = Media("http://playerservices.streamtheworld.com/api/livestream-redirect/JBFMAAC1.aac") # , cmd1)
# media.get_mrl()
p.set_media(media)
p.play()
e = p.event_manager()
e.event_attach(EventType.MediaMetaChanged, _media_cb, media)
e.event_attach(EventType.MediaParsedChanged, _media_cb, media)
# define the meta data to show
meta = {Meta.Album: None,
Meta.Genre: None,
Meta.NowPlaying: None}
while True: # loop forever
# XXX using MediaParseFlag.local is not any different
media.parse_with_options(MediaParseFlag.network, 2) # 2 sec timeout
# XXX media.get_parsed_status() always returns .skipped
for k in meta.keys():
v = media.get_meta(k)
if v != meta[k]:
print("{} - {}".format(k, v))
meta[k] = v
sleep(2)
Sample output after about one hour play time: ... Meta.NowPlaying - Phil Collins - A Groove Kind Of Love Meta.Genre - Adult Contemporary Meta.NowPlaying - Tony Braxton - How could an angel break my heart Meta.NowPlaying - Zeca Baleiro - Flor da Pele Meta.NowPlaying - Suzanne Vega - Luka Meta.NowPlaying - Lionel Richie - Love Will Conquer All Meta.NowPlaying - Tina Turner - Let's Stay Together Meta.NowPlaying - Adriana Calcanhotto - Lindo lago do Amor Meta.NowPlaying - Harry Styles - Sign of the Times Meta.NowPlaying - Blue Bell - Change The World Meta.NowPlaying - Ivan Lins - Vieste Meta.NowPlaying - 10 cc - I'm not in love Meta.NowPlaying - Bread - If Meta.NowPlaying - Whitney Houston - Exhale Meta.NowPlaying - Marving Gaye - Stop, Look, Listen Meta.NowPlaying - Michael Jackson - I just can't stop loving you Meta.NowPlaying - Peter Frampton - I'm in you Meta.NowPlaying - Lillo Thomas - Just My Imagination Meta.NowPlaying - Paul McCrane - Is it OK if i call you mine Meta.NowPlaying - Earth, Wind & Fire - Could It Be Right Meta.NowPlaying - The Beatles - Yesterday Meta.NowPlaying - Morris Albert - Feelings ... 1) each .NowPlaying message shows up slightly before the previous ends 2) callback function _media_cb above is never called
I'm trying to record and get song information (title and artist) from web radios using python-vlc lib. The recording functionality is working well but the media parse to get the song information doesn't work! This is my code:
`inst = vlc.Instance() # Create a VLC instance
p = inst.media_player_new() # Create a player instance cmd1 = "sout=file/ts:%s" % outfile media = inst.media_new("http://playerservices.streamtheworld.com/api/livestream-redirect/JBFMAAC1.aac", cmd1) media.get_mrl()
p.set_media(media) p.play()
media.parse()
for i in range(13): print("{} - {}".format(i, media.get_meta(i)))`
It's always returning "MediaParsedStatus.skipped" status. And all song information returns "None". I tested the same radio in VLC App and there it works fine. Anyone can help me? thanks in advance.