Esempio n. 1
0
def expand_item( accum_ids, asset_def, images_dct, movies_dct ):

	print "mov->", movies_dct.keys()

	# get the movie asset name...
	asset_name = asset_def["asset_name"]

	# get the base def of the item...
	item_def = movies_dct[asset_name][0]

	# get type...
	typ = "file"
	if item_def.has_key("type"):
		typ = item_def["type"]

	# if video type, branch here...
	if typ == "vimeo":
		return expand_vimeo_item( accum_ids, asset_def, images_dct, movies_dct )
	elif typ == "brightcove":
		return expand_brightcove_item( accum_ids, asset_def, images_dct, movies_dct )

	# get the alt movie asset name, if any...
	alt_name = ""
	if asset_def.has_key("alt"): alt_name = asset_def["alt"]

	# get an html id for video element...	
	htmlid = common.get_id( asset_name, accum_ids )
	accum_ids.append(htmlid)

	# get the poster path, if any...
	poster_path = ""
	if item_def["poster"].strip()!="":
		poster = item_def["poster"].strip()
		poster_path = gen_images.get_item_path( poster, images_dct )
		poster_path = common.create_path( poster_path )

	# get the alternate movie path src, if any...
	alt_path = ""
	if alt_name != "":
		alt_path = get_item_path( alt_name, movies_dct )
		alt_path = common.create_path( alt_path )

	# finally, get the primary movie path src...
	movie_path = get_item_path( asset_name, movies_dct )
	movie_path = common.create_path( movie_path )

	# get coords for def...
	x = asset_def['x']
	y = asset_def['y']
	z = asset_def['z']

	# create the style...
	style  = ""
	style += common.emit_line( "#%s {" % htmlid )
	style += common.emit_line( "position: absolute;")
	style += common.emit_line( "left: %dpx;" % int(x) )
	style += common.emit_line( "top: %dpx;" % int(y) )
	style += common.emit_line( "z-index: %d;" % int(z) )
	style += common.emit_line( "visibility: hidden;" )
	style += common.emit_line( "}" )

	if poster_path == "":	
		content = common.emit_line( "<video controls id=%s ><source src=\"%s\" />CANNOT LOAD</video>" % (htmlid, movie_path) )
	else:
		if alt_path != "":
			content = common.emit_line( "<video controls id=%s poster=\"%s\" >" % ( htmlid, poster_path ) )
			content += common.emit_line( "<source src=\"%s\" />" % movie_path )
			content += common.emit_line( "<source src=\"%s\" />" % alt_path )
			content += common.emit_line( "</video>" )
		else:	
			content = common.emit_line( "<video controls id=%s poster=\"%s\" ><source src=\"%s\" /></video>" % (htmlid, poster_path, movie_path) )

	scriptlet_dct = {}
	scriptlet_dct['on'] = "document.getElementById('%s').style.visibility='visible';" % htmlid
	scriptlet_dct['off'] = "document.getElementById('%s').style.visibility='hidden';" % htmlid
	scriptlet_dct['init'] = "document.getElementById('%s').style.visibility='visible';" % htmlid
	
	return [ style, content, scriptlet_dct ]
Esempio n. 2
0
def get_img_path( imgref, images_dct ):
	path = gen_images.get_item_path( imgref, images_dct )
	return path