segunda-feira, 26 de junho de 2017

Python VLC binding- playing a playlist Stream

import requests
import vlc
from time import sleep
urls = [
    'http://stream02.ustream.ca:8000/ckrl128.mp3',
    'file:///home/rolf/test.m3u',
    'file:///home/rolf/happy.mp3',
    'http://cast.radiogroup.com.ua:8000/europaplus',
    'http://ckik.streamon.fm:8000/CKIK-64k.aac?starttime=1460718782',
    ]

playlists = set(['pls','m3u'])

Instance = vlc.Instance()

for url in urls:
    ext = (url.rpartition(".")[2])[:3]
    test_pass = False  
    try:
        if url[:4] == 'file':
            test_pass = True
        else:
            r = requests.get(url, stream=True)
            test_pass = r.ok
    except Exception as e:
        print('failed to get stream: {e}'.format(e=e))
        test_pass = False
    else:
        if test_pass:
            print('Sampling for 15 seconds')
            player = Instance.media_player_new()
            Media = Instance.media_new(url)
            Media_list = Instance.media_list_new([url])
            Media.get_mrl()
            player.set_media(Media)
            if ext in playlists:
                list_player = Instance.media_list_player_new()
                list_player.set_media_list(Media_list)
                if list_player.play() == -1:
                    print ("Error playing playlist")
            else:
                if player.play() == -1:
                    print ("Error playing Stream")
            sleep(15)
            if ext in playlists:
                list_player.stop()
            else:
                player.stop()

        else:
            print('error getting the audio')
Redirect VLC Stream


vlc -vvv mms://server01/radio01 --sout="#transcode{vcodec=none,acodec=vorb,ab=128,channels=2,samplerate=44100}:standard{access=shout,mux=ogg,dst=user:password@icecastServer:8000/channel1.ogg}"



        /channel1.ogg

        user
        password

        100
         
       
        1
        1
       
       
         
jQuery111107796130166325395_1499533156559({"currentlisteners":1,"peaklisteners":4,"maxlisteners":100,"uniquelisteners":1,"averagetime":90,"servergenre":"Pop","servergenre2":"","servergenre3":"","servergenre4":"","servergenre5":"","serverurl":"http:\/\/www.radiosa.net.br","servertitle":"Radio S.A - Curitiba - Paran","songtitle":"Ramones - Pet Sematary","streamhits":110,"streamstatus":1,"backupstatus":0,"streamlisted":0,"streamlistederror":200,"streampath":"\/","streamuptime":4332,"bitrate":"32","content":"audio\/aacp","version":"2.4.7.256 (posix(linux x64))"})
http://07.stmip.net:9364/live;stream.mp3

http://www.radiosa.net.br/ 

http://painelstream.com/xplay/9364 

#EXTM3U
#EXTINF:-1,Radio S.A - Curitiba - Paran
http://07.stmip.net:9364/
    
Below the JPlayer:


Player: http://jplayer.org/
Media Support

HTML5: mp3, mp4 (AAC/H.264), ogg (Vorbis/Theora), webm (Vorbis/VP8), wav
Flash: mp3, mp4 (AAC/H.264), rtmp, flv
Postar um comentário