def addMedia(self, lat, lon, datastoreOb): rec = Recorded() #default photo rec.type = Constants.TYPE_PHOTO if ((datastoreOb.metadata['mime_type'] == "video/ogg") or (datastoreOb.metadata['mime_type'] == "audio/ogg")): rec.type = Constants.TYPE_VIDEO rec.source = Recorded.SOURCE_DATASTORE rec.datastoreOb = datastoreOb rec.datastoreId = datastoreOb.object_id rec.tags = "" if (datastoreOb.metadata.has_key("tags")): rec.tags = datastoreOb.metadata['tags'] rec.latitude = lat rec.longitude = lon colors = datastoreOb.metadata['icon-color'] colorStroke, colorFill = colors.split(",") rec.colorStroke = Color() rec.colorStroke.init_hex(colorStroke) rec.colorFill = Color() rec.colorFill.init_hex(colorFill) thumbPixbuf = None if (datastoreOb.metadata.has_key("preview")): try: thumb = datastoreOb.metadata['preview'] if thumb[1:4] == 'PNG': pbl = gtk.gdk.PixbufLoader() pbl.write(thumb) pbl.close() thumbPixbuf = pbl.get_pixbuf() else: thumbPixbuf = utils.getPixbufFromString(thumb) except: pass if (thumbPixbuf == None): #try to create the thumbnail yourself... if (rec.type == Constants.TYPE_PHOTO): try: #load in the image, make a thumbnail thumbPixbuf = gtk.gdk.pixbuf_new_from_file_at_size( rec.getFilepath(), 320, 240) except: pass if (thumbPixbuf == None): #i give up. load in a blank image from the activity itself. thumbPath = os.path.join(self.ca.htmlPath, "1.jpg") thumbPixbuf = gtk.gdk.pixbuf_new_from_file(thumbPath) thumbFilepath = os.path.join(Instance.instancePath, "thumb.png") thumbFilepath = utils.getUniqueFilepath(thumbFilepath, 0) thumbPixbuf.save(thumbFilepath, "png", {}) rec.thumbFilename = os.path.basename(thumbFilepath) self.recs.append(rec) return rec
def addMedia(self, lat, lon, datastoreOb): rec = Recorded() #default photo rec.type = Constants.TYPE_PHOTO if((datastoreOb.metadata['mime_type'] == "video/ogg") or (datastoreOb.metadata['mime_type'] == "audio/ogg")): rec.type = Constants.TYPE_VIDEO rec.source = Recorded.SOURCE_DATASTORE rec.datastoreOb = datastoreOb rec.datastoreId = datastoreOb.object_id rec.tags = "" if (datastoreOb.metadata.has_key("tags")): rec.tags = datastoreOb.metadata['tags'] rec.latitude = lat rec.longitude = lon colors = datastoreOb.metadata['icon-color'] colorStroke, colorFill = colors.split(",") rec.colorStroke = Color() rec.colorStroke.init_hex(colorStroke) rec.colorFill = Color() rec.colorFill.init_hex(colorFill) thumbPixbuf = None if (datastoreOb.metadata.has_key("preview")): try: thumb = datastoreOb.metadata['preview'] if thumb[1:4] == 'PNG': pbl = GdkPixbuf.PixbufLoader() pbl.write(thumb) pbl.close() thumbPixbuf = pbl.get_pixbuf() else: thumbPixbuf = utils.getPixbufFromString(thumb) except: pass if (thumbPixbuf == None): #try to create the thumbnail yourself... if (rec.type == Constants.TYPE_PHOTO): try: #load in the image, make a thumbnail thumbPixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(rec.getFilepath(), 320, 240) except: pass if (thumbPixbuf == None): #i give up. load in a blank image from the activity itself. thumbPath = os.path.join(self.ca.htmlPath, "1.jpg") thumbPixbuf = GdkPixbuf.Pixbuf.new_from_file(thumbPath) thumbFilepath = os.path.join(Instance.instancePath, "thumb.png") thumbFilepath = utils.getUniqueFilepath(thumbFilepath, 0) thumbPixbuf.save( thumbFilepath, "png", {} ) rec.thumbFilename = os.path.basename(thumbFilepath) self.recs.append(rec) return rec