def get_uris(self, media_file): """Return a list of URIs from which the stored file can be accessed. :type media_file: :class:`~mediacore.model.media.MediaFile` :param media_file: The associated media file object. :rtype: list :returns: All :class:`StorageURI` tuples for this file. """ uris = [] # Remotely accessible URL url = url_for(controller='/media', action='serve', id=media_file.id, slug=media_file.media.slug, container=media_file.container, qualified=True) uris.append(StorageURI(media_file, 'http', url, None)) # An optional streaming RTMP URI rtmp_server_uri = self._data.get('rtmp_server_uri', None) if rtmp_server_uri: uris.append(StorageURI(media_file, 'rtmp', media_file.unique_id, rtmp_server_uri)) # Remotely *download* accessible URL url = url_for(controller='/media', action='serve', id=media_file.id, slug=media_file.media.slug, container=media_file.container, qualified=True, download=1) uris.append(StorageURI(media_file, 'download', url, None)) # Internal file URI that will be used by MediaController.serve path = urlunsplit(('file', '', self._get_path(media_file.unique_id), '', '')) uris.append(StorageURI(media_file, 'file', path, None)) return uris
def test_can_generate_static_url_with_proxy_prefix(self): self.pylons_config['proxy_prefix'] = '/proxy' request = self.init_fake_request(server_name='server.example') request.environ['SCRIPT_NAME'] = '/proxy' assert_equals('/proxy/media', url_for('/media')) qualified_media_url = url_for('/media', qualified=True) assert_equals('http://server.example:80/proxy/media', qualified_media_url)
def embed_iframe(media, width=400, height=225, frameborder=0, **kwargs): """Return an <iframe> tag that loads our universal player. :type media: :class:`mediacore.model.media.Media` :param media: The media object that is being rendered, to be passed to all instantiated player objects. :rtype: :class:`genshi.builder.Element` :returns: An iframe element stream. """ src = url_for(controller='/media', action='embed_player', slug=media.slug, qualified=True) tag = Element('iframe', src=src, width=width, height=height, frameborder=frameborder, **kwargs) # some software is known not to work with self-closing iframe tags # ('<iframe ... />'). Several WordPress instances are affected as well as # TWiki http://mediadrop.net/community/topic/embed-iframe-closing-tag tag.append('') return tag
def embed_iframe(media, width=400, height=225, frameborder=0, **kwargs): """Return an <iframe> tag that loads our universal player. :type media: :class:`mediacore.model.media.Media` :param media: The media object that is being rendered, to be passed to all instantiated player objects. :rtype: :class:`genshi.builder.Element` :returns: An iframe element stream. """ src = url_for(controller="/media", action="embed_player", slug=media.slug, qualified=True) tag = Element("iframe", src=src, width=width, height=height, frameborder=frameborder, **kwargs) return tag
def flashvars(self): """Return a python dict of flashvars for this player.""" youtube = self.get_uris(container='youtube') rtmp = self.get_uris(scheme=RTMP) http = self.get_uris(scheme=HTTP) audio_desc = self.get_uris(type=AUDIO_DESC) captions = self.get_uris(type=CAPTIONS) vars = { 'image': thumb_url(self.media, 'l', qualified=self.qualified), 'autostart': self.autoplay, } if youtube: vars['provider'] = 'youtube' vars['file'] = str(youtube[0]) elif rtmp: if len(rtmp) > 1: # For multiple RTMP bitrates, use Media RSS playlist vars = {} vars['playlistfile'] = url_for( controller='/media', action='jwplayer_rtmp_mrss', slug=self.media.slug, ) else: # For a single RTMP stream, use regular Flash vars. rtmp_uri = rtmp[0] vars['file'] = rtmp_uri.file_uri vars['streamer'] = rtmp_uri.server_uri vars['provider'] = 'rtmp' else: http_uri = http[0] vars['provider'] = self.providers[http_uri.file.type] vars['file'] = str(http_uri) plugins = [] if rtmp: plugins.append('rtmp') if audio_desc: plugins.append('audiodescription'); vars['audiodescription.file'] = audio_desc[0].uri if captions: plugins.append('captions'); vars['captions.file'] = captions[0].uri if plugins: vars['plugins'] = ','.join(plugins) return vars
def embed_iframe(media, width=400, height=225, frameborder=0, **kwargs): """Return an <iframe> tag that loads our universal player. :type media: :class:`mediacore.model.media.Media` :param media: The media object that is being rendered, to be passed to all instantiated player objects. :rtype: :class:`genshi.builder.Element` :returns: An iframe element stream. """ src = url_for(controller='/media', action='embed_player', slug=media.slug, qualified=True) tag = Element('iframe', src=src, width=width, height=height, frameborder=frameborder, **kwargs) # some software is known not to work with self-closing iframe tags # ('<iframe ... />'). Several WordPress instances are affected as well as # TWiki http://opensource.mediacore.com/community/topic/embed-iframe-closing-tag tag.append('') return tag
def embed_iframe(media, width=400, height=225, frameborder=0, **kwargs): """Return an <iframe> tag that loads our universal player. :type media: :class:`mediacore.model.media.Media` :param media: The media object that is being rendered, to be passed to all instantiated player objects. :rtype: :class:`genshi.builder.Element` :returns: An iframe element stream. """ src = url_for(controller='/media', action='embed_player', slug=media.slug, qualified=True) tag = Element('iframe', src=src, width=width, height=height, frameborder=frameborder, **kwargs) return tag
def js_url(self): return url_for('/scripts/third-party/jw_player/jwplayer.min.js', qualified=self.qualified)
def swf_url(self): return url_for('/scripts/third-party/jw_player/player.swf', qualified=self.qualified)
def swf_url(self): """Return the flash player URL.""" return url_for('/scripts/third-party/flowplayer/flowplayer-3.2.14.swf', qualified=self.qualified)
def js(source): if config['debug'] and source in js_sources_debug: return url_for(js_sources_debug[source]) return url_for(js_sources[source])
def swf_url(self): """Return the flash player URL.""" return url_for('/scripts/third-party/jw_player/player.swf', qualified=self.qualified)
def swf_url(self): """Return the flash player URL.""" return url_for('/m3u8player/public/scripts/third-party/HLSProviderChromeless.swf', qualified=self.qualified)
def update_params(self, d): super(LinkifyMixin, self).update_params(d) d.link = url_for(d.link)