示例#1
0
    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)
示例#3
0
    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)
示例#4
0
文件: players.py 项目: isaleem/cumin
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
示例#5
0
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
示例#6
0
    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
示例#7
0
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
示例#8
0
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
示例#9
0
 def js_url(self):
     return url_for('/scripts/third-party/jw_player/jwplayer.min.js',
                    qualified=self.qualified)
示例#10
0
 def swf_url(self):
     return url_for('/scripts/third-party/jw_player/player.swf',
                    qualified=self.qualified)
示例#11
0
 def swf_url(self):
     """Return the flash player URL."""
     return url_for('/scripts/third-party/flowplayer/flowplayer-3.2.14.swf',
                    qualified=self.qualified)
示例#12
0
文件: players.py 项目: isaleem/cumin
 def js_url(self):
     return url_for('/scripts/third-party/jw_player/jwplayer.min.js',
                    qualified=self.qualified)
示例#13
0
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])
示例#14
0
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])
示例#15
0
 def swf_url(self):
     """Return the flash player URL."""
     return url_for('/scripts/third-party/jw_player/player.swf',
                    qualified=self.qualified)
示例#16
0
文件: players.py 项目: isaleem/cumin
 def swf_url(self):
     """Return the flash player URL."""
     return url_for('/scripts/third-party/flowplayer/flowplayer-3.2.14.swf',
                    qualified=self.qualified)
示例#17
0
文件: players.py 项目: isaleem/cumin
 def swf_url(self):
     return url_for('/scripts/third-party/jw_player/player.swf',
                    qualified=self.qualified)
示例#18
0
 def swf_url(self):
     """Return the flash player URL."""
     return url_for('/m3u8player/public/scripts/third-party/HLSProviderChromeless.swf', qualified=self.qualified)
示例#19
0
文件: __init__.py 项目: isaleem/cumin
 def update_params(self, d):
     super(LinkifyMixin, self).update_params(d)
     d.link = url_for(d.link)
示例#20
0
 def update_params(self, d):
     super(LinkifyMixin, self).update_params(d)
     d.link = url_for(d.link)