def test_link_dimensions(self):
        _createObjectByType('Link', self.folder, 'my-video-link')
        link = self.folder['my-video-link']
        link.setRemoteUrl('file://{0}'.format(
            os.path.join(os.path.dirname(__file__), 'barsandtone.flv')))
        zope.interface.alsoProvides(link, IVideo)

        self.assertEqual(IMediaInfo(link).width, None)
        self.assertEqual(IMediaInfo(link).height, None)

        ChangeLinkView(link, StubEvent(link))

        self.assertEqual(IMediaInfo(link).width, 360)
        self.assertEqual(IMediaInfo(link).height, 288)
Example #2
0
    def handleVideo(self):
        video = IVideo.providedBy(self.content)
        
        if not video:
            alsoProvides(self.content, IVideo)
            self.object.reindexObject(idxs=['object_provides'])

        info = IMediaInfo(self.content)

        if (not video) or (info.height == None or info.width == None):
            handle = self.file_handle
            try:
                metadata = parse_raw(handle)
                height, width = scale_from_metadata(metadata)
                handle.close()
            except StreamError:
                height = width = None

            if height and width:
                info.height = height
                info.width = width            
    def handleVideo(self):
        video = IVideo.providedBy(self.content)

        if not video:
            alsoProvides(self.content, IVideo)
            self.object.reindexObject(idxs=['object_provides'])

        info = IMediaInfo(self.content)

        if (not video) or (info.height is None or info.width is None):
            handle = self.file_handle
            try:
                metadata = parse_raw(handle)
                height, width = scale_from_metadata(metadata)
                handle.close()
            except StreamError:
                height = width = None

            if height and width:
                info.height = height
                info.width = width
Example #4
0
    def __init__(self, context, request):
        super(File, self).__init__(context, request)

        self.info = IMediaInfo(self.context, None)

        self.height = self.info is not None and self.info.height or None
        self.width = self.info is not None and self.info.width or None
        self._audio_only = self.info is not None and self.info.audio_only or None

        if self.height and self.width:
            self._scale = "height: %dpx; width: %dpx;" % (self.height,
                                                          self.width)
        else:
            self._scale = ""
Example #5
0
 def mutator(value, **kw):
     try:
         value = int(value)
     except:
         value = None
     IMediaInfo(instance).height = value
Example #6
0
 def edit_accessor(**kw):
     return IMediaInfo(instance).height
Example #7
0
 def accessor(**kw):
     return IMediaInfo(instance).width
Example #8
0
 def last_migrate_mediaData(self):
     media = IMediaInfo(self.old)
     notify(ObjectInitializedEvent(self.new))