Ejemplo n.º 1
0
    def player_vars(self):
        """Return a python dict of vars for this player."""
        vars = {
            'autostart': self.autoplay,
            'height': self.adjusted_height,
            'width': self.adjusted_width,
            'controlbar': 'bottom',
            'players': [
                # XXX: Currently flash *must* come first for the RTMP/HTTP logic.
                {'type': 'flash', 'src': self.swf_url()},
                {'type': 'html5'},
                {'type': 'download'},
            ],
        }
        playlist = self.playlist()
        plugins = self.plugins()
        if playlist:
            vars['playlist'] = playlist
        if plugins:
            vars['plugins'] = plugins

        # Playlists have 'image's and <video> elements have provide 'poster's,
        # but <audio> elements have no 'poster' attribute. Set an image via JS:
        if self.media.type == AUDIO and not playlist:
            vars['image'] = thumb_url(self.media, 'l', qualified=self.qualified)

        return vars
Ejemplo n.º 2
0
    def flashvars(self):
        playlist = []
        vars = {
            'canvas': {'backgroundColor': '#000', 'backgroundGradient': 'none'},
            'clip': {'scaling': 'fit'},
            'playlist': playlist,
        }

        # Show a preview image
        if self.media.type == AUDIO or not self.autoplay:
            playlist.append({
                'url': thumb_url(self.media, 'l', qualified=self.qualified),
                'autoPlay': True,
                'autoBuffer': True,
            })

        playlist.append({
            'url': self.file.play_url(qualified=self.qualified),
            'autoPlay': self.autoplay,
            'autoBuffer': self.autoplay or self.autobuffer,
        })

        # Flowplayer wants these options passed as an escaped JSON string
        # inside a single 'config' flashvar. When using the flowplayer's
        # own JS, this is automatically done, but since we use Swiff, a
        # SWFObject clone, we have to do this ourselves.
        vars = {'config': json.dumps(vars, separators=(',', ':'))}
        return vars
Ejemplo n.º 3
0
    def flashvars(self):
        if self.is_youtube_on_ipod():
            return {}

        vars = {
            'image': thumb_url(self.media, 'l', qualified=self.qualified),
            'autostart': self.autoplay,
        }

        if self.file.container == 'youtube':
            vars['provider'] = 'youtube'
            vars['file'] = self.file.link_url(qualified=self.qualified)
        else:
            vars['provider'] = self.providers[self.file.type]
            vars['file'] = self.file.play_url(qualified=self.qualified)

        plugins = []
        audio_desc = self.media.audio_desc
        captions = self.media.captions
        if audio_desc:
            plugins.append('audiodescription');
            vars['audiodescription.file'] = audio_desc.play_url(qualified=self.qualified)
        if captions:
            plugins.append('captions');
            vars['captions.file'] = captions.play_url(qualified=self.qualified)
        if plugins:
            vars['plugins'] = ','.join(plugins)

        return vars
Ejemplo n.º 4
0
    def flashvars(self):
        """Return a python dict of flashvars for this player."""
        http_uri = self.uris[0]

        playlist = []
        vars = {
            'canvas': {'backgroundColor': '#000', 'backgroundGradient': 'none'},
            'plugins': {
                'controls': {'autoHide': True},
            },
            'clip': {'scaling': 'fit'},
            'playlist': playlist,
        }

        # Show a preview image
        if self.media.type == AUDIO or not self.autoplay:
            playlist.append({
                'url': thumb_url(self.media, 'l', qualified=self.qualified),
                'autoPlay': True,
                'autoBuffer': True,
            })

        playlist.append({
            'url': str(http_uri),
            'autoPlay': self.autoplay,
            'autoBuffer': self.autoplay or self.autobuffer,
        })

        # Flowplayer wants these options passed as an escaped JSON string
        # inside a single 'config' flashvar. When using the flowplayer's
        # own JS, this is automatically done, but since we use Swiff, a
        # SWFObject clone, we have to do this ourselves.
        vars = {'config': simplejson.dumps(vars, separators=(',', ':'))}
        return vars
Ejemplo n.º 5
0
    def flashvars(self):
        """Return a python dict of flashvars for this player."""
        http_uri = self.uris[0]

        playlist = []
        vars = {
            "canvas": {"backgroundColor": "#000", "backgroundGradient": "none"},
            "plugins": {"controls": {"autoHide": True}},
            "clip": {"scaling": "fit"},
            "playlist": playlist,
        }

        # Show a preview image
        if self.media.type == AUDIO or not self.autoplay:
            playlist.append(
                {"url": thumb_url(self.media, "l", qualified=self.qualified), "autoPlay": True, "autoBuffer": True}
            )

        playlist.append(
            {"url": str(http_uri), "autoPlay": self.autoplay, "autoBuffer": self.autoplay or self.autobuffer}
        )

        # Flowplayer wants these options passed as an escaped JSON string
        # inside a single 'config' flashvar. When using the flowplayer's
        # own JS, this is automatically done, but since we use Swiff, a
        # SWFObject clone, we have to do this ourselves.
        vars = {"config": simplejson.dumps(vars, separators=(",", ":"))}
        return vars
Ejemplo n.º 6
0
 def html5_attrs(self):
     attrs = {
         'src': self.file.play_url(qualified=self.qualified),
         'controls': 'controls',
     }
     if self.autoplay:
         attrs['autoplay'] = 'autoplay'
     elif self.autobuffer:
         # This isn't included in the HTML5 spec, but Safari supports it
         attrs['autobuffer'] = 'autobuffer'
     if self.file.type == VIDEO:
         attrs['poster'] = thumb_url(self.media, 'l', qualified=self.qualified)
     return attrs
Ejemplo n.º 7
0
    def playlist(self):
        if self.uris:
            return None

        if self.rtmp_uris:
            return self.rtmp_playlist()

        uri = self.flash_uris[0]
        return [{
            'image': thumb_url(self.media, 'l', qualified=self.qualified),
            'file': str(uri),
            'duration': self.media.duration,
            'provider': self.providers[uri.file.type],
        }]
Ejemplo n.º 8
0
    def playlist(self):
        if self.uris:
            return None

        if self.rtmp_uris:
            return self.rtmp_playlist()

        uri = self.flash_uris[0]
        return [{
            'image': thumb_url(self.media, 'l', qualified=self.qualified),
            'file': str(uri),
            'duration': self.media.duration,
            'provider': self.providers[uri.file.type],
        }]
Ejemplo n.º 9
0
 def html5_attrs(self):
     attrs = {
         "id": self.elem_id,
         "controls": "controls",
         "width": self.adjusted_width,
         "height": self.adjusted_height,
     }
     if self.autoplay:
         attrs["autoplay"] = "autoplay"
     elif self.autobuffer:
         # This isn't included in the HTML5 spec, but Safari supports it
         attrs["autobuffer"] = "autobuffer"
     if self.media.type == VIDEO:
         attrs["poster"] = thumb_url(self.media, "l", qualified=self.qualified)
     return attrs
Ejemplo n.º 10
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
Ejemplo n.º 11
0
 def html5_attrs(self):
     attrs = {
         'id': self.elem_id,
         'controls': 'controls',
         'width': self.adjusted_width,
         'height': self.adjusted_height,
     }
     if self.autoplay:
         attrs['autoplay'] = 'autoplay'
     elif self.autobuffer:
         # This isn't included in the HTML5 spec, but Safari supports it
         attrs['autobuffer'] = 'autobuffer'
     if self.media.type == VIDEO:
         attrs['poster'] = thumb_url(self.media, 'l',
                                     qualified=self.qualified)
     return attrs
Ejemplo n.º 12
0
 def rtmp_playlist(self):
     levels = []
     item = {
         "streamer": self.rtmp_uris[0].server_uri,
         "provider": "rtmp",
         "levels": levels,
         "duration": self.media.duration,
     }
     # If no HTML5 uris exist, no <video> tag will be output, so we have to
     # say which thumb image to use. Otherwise it's unnecessary bytes.
     if not self.uris:
         item["image"] = thumb_url(self.media, "l", qualified=self.qualified)
     for uri in self.rtmp_uris:
         levels.append({"file": uri.file_uri, "bitrate": uri.file.bitrate, "width": uri.file.width})
     playlist = [item]
     return playlist
Ejemplo n.º 13
0
    def playlist(self):
        if self.uris:
            return None

        if self.rtmp_uris:
            return self.rtmp_playlist()

        uri = self.flash_uris[0]
        return [
            {
                "image": thumb_url(self.media, "l", qualified=self.qualified),
                "file": str(uri),
                "duration": self.media.duration,
                "provider": self.providers[uri.file.type],
            }
        ]
Ejemplo n.º 14
0
 def rtmp_playlist(self):
     levels = []
     item = {'streamer': self.rtmp_uris[0].server_uri,
             'provider': 'rtmp',
             'levels': levels,
             'duration': self.media.duration}
     # If no HTML5 uris exist, no <video> tag will be output, so we have to
     # say which thumb image to use. Otherwise it's unnecessary bytes.
     if not self.uris:
         item['image'] = thumb_url(self.media, 'l', qualified=self.qualified)
     for uri in self.rtmp_uris:
         levels.append({
             'file': uri.file_uri,
             'bitrate': uri.file.bitrate,
             'width': uri.file.width,
         })
     playlist = [item]
     return playlist