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)
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
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 = ""
def mutator(value, **kw): try: value = int(value) except: value = None IMediaInfo(instance).height = value
def edit_accessor(**kw): return IMediaInfo(instance).height
def accessor(**kw): return IMediaInfo(instance).width
def last_migrate_mediaData(self): media = IMediaInfo(self.old) notify(ObjectInitializedEvent(self.new))