prise en charge du rtmp
This commit is contained in:
parent
d5ea1ffc2c
commit
16edbd9141
3 changed files with 12 additions and 9 deletions
|
|
@ -89,10 +89,11 @@ class Radioob(ReplApplication):
|
||||||
return 1
|
return 1
|
||||||
try:
|
try:
|
||||||
player_name = self.config.get('media_player')
|
player_name = self.config.get('media_player')
|
||||||
|
media_player_args = self.config.get('media_player_args')
|
||||||
if not player_name:
|
if not player_name:
|
||||||
self.logger.debug(u'You can set the media_player key to the player you prefer in the radioob '
|
self.logger.debug(u'You can set the media_player key to the player you prefer in the radioob '
|
||||||
'configuration file.')
|
'configuration file.')
|
||||||
self.player.play(radio.streams[0], player_name=player_name)
|
self.player.play(radio.streams[0], player_name=player_name, player_args=media_player_args)
|
||||||
except (InvalidMediaPlayer, MediaPlayerNotFound), e:
|
except (InvalidMediaPlayer, MediaPlayerNotFound), e:
|
||||||
print '%s\nRadio URL: %s' % (e, radio.streams[0].url)
|
print '%s\nRadio URL: %s' % (e, radio.streams[0].url)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,10 +147,11 @@ class Videoob(ReplApplication):
|
||||||
return 4
|
return 4
|
||||||
try:
|
try:
|
||||||
player_name = self.config.get('media_player')
|
player_name = self.config.get('media_player')
|
||||||
|
media_player_args = self.config.get('media_player_args')
|
||||||
if not player_name:
|
if not player_name:
|
||||||
self.logger.info(u'You can set the media_player key to the player you prefer in the videoob '
|
self.logger.info(u'You can set the media_player key to the player you prefer in the videoob '
|
||||||
'configuration file.')
|
'configuration file.')
|
||||||
self.player.play(video, player_name=player_name)
|
self.player.play(video, player_name=player_name, player_args=media_player_args)
|
||||||
except (InvalidMediaPlayer, MediaPlayerNotFound), e:
|
except (InvalidMediaPlayer, MediaPlayerNotFound), e:
|
||||||
print '%s\nVideo URL: %s' % (e, video.url)
|
print '%s\nVideo URL: %s' % (e, video.url)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class MediaPlayer(object):
|
||||||
return player_name
|
return player_name
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def play(self, media, player_name=None):
|
def play(self, media, player_name=None, player_args=None):
|
||||||
"""
|
"""
|
||||||
Play a media object, using programs from the PLAYERS list.
|
Play a media object, using programs from the PLAYERS list.
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ class MediaPlayer(object):
|
||||||
if player_name is None:
|
if player_name is None:
|
||||||
raise MediaPlayerNotFound()
|
raise MediaPlayerNotFound()
|
||||||
if media.url.startswith('rtmp'):
|
if media.url.startswith('rtmp'):
|
||||||
self._play_rtmp(media, player_name)
|
self._play_rtmp(media, player_name, args=player_args)
|
||||||
else:
|
else:
|
||||||
self._play_default(media, player_name)
|
self._play_default(media, player_name)
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@ class MediaPlayer(object):
|
||||||
print 'Invoking "%s %s".' % (player_name, media.url)
|
print 'Invoking "%s %s".' % (player_name, media.url)
|
||||||
os.spawnlp(os.P_WAIT, player_name, player_name, media.url)
|
os.spawnlp(os.P_WAIT, player_name, player_name, media.url)
|
||||||
|
|
||||||
def _play_rtmp(self, media, player_name):
|
def _play_rtmp(self, media, player_name, args):
|
||||||
"""
|
"""
|
||||||
Download data with rtmpdump and pipe them to a media player.
|
Download data with rtmpdump and pipe them to a media player.
|
||||||
|
|
||||||
|
|
@ -117,10 +117,11 @@ class MediaPlayer(object):
|
||||||
|
|
||||||
rtmp += ' --quiet'
|
rtmp += ' --quiet'
|
||||||
|
|
||||||
args = None
|
if args is None :
|
||||||
for (binary, stdin_args) in PLAYERS:
|
for (binary, stdin_args) in PLAYERS:
|
||||||
if binary == player_name:
|
if binary == player_name:
|
||||||
args = stdin_args
|
args = stdin_args
|
||||||
|
|
||||||
assert args is not None
|
assert args is not None
|
||||||
|
|
||||||
print ':: Streaming from %s' % media_url
|
print ':: Streaming from %s' % media_url
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue