001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.tag; 020 021 022import javax.servlet.jsp.tagext.Tag; 023 024import lucee.runtime.exp.ApplicationException; 025import lucee.runtime.exp.PageException; 026import lucee.runtime.ext.tag.TagSupport; 027 028/** 029 * implementation of the tag Compiler 030 */ 031public class VideoPlayerParam extends TagSupport { 032 033 private VideoPlayerParamBean param=new VideoPlayerParamBean(); 034 035 @Override 036 public void release() { 037 super.release(); 038 param=new VideoPlayerParamBean(); 039 } 040 041 /** 042 * @param video the video to set 043 * @throws PageException 044 */ 045 public void setVideo(String video) throws PageException { 046 param.setVideo(pageContext,video); 047 } 048 049 /** 050 * @param flash the flash to set 051 */ 052 public void setFlash(String flash) throws PageException { 053 param.setFlash(pageContext,flash); 054 } 055 056 /** 057 * @param show the show to set 058 */ 059 public void setShow(String show) throws PageException { 060 param.setShow(show); 061 } 062 063 /** 064 * @param index the index to set 065 * @throws PageException 066 */ 067 public void setIndex(double dIndex) throws PageException { 068 param.setIndex((int) dIndex); 069 } 070 /*public void setAutostart(boolean autostart) { 071 param.setAutostart(autostart); 072 }*/ 073 public void setTitle(String title) { 074 param.setTitle(title); 075 } 076 077 /** 078 * @param preview the preview to set 079 * @throws PageException 080 */ 081 public void setPreview(String preview) throws PageException { 082 param.setImage(pageContext,preview); 083 } 084 public void setImage(String preview) throws PageException { 085 param.setImage(pageContext,preview); 086 } 087 public void setLink(String link) { 088 param.setLink(link); 089 } 090 public void setAuthor(String author) { 091 param.setAuthor(author); 092 } 093 094 @Override 095 public int doStartTag() throws PageException { 096 097 if(param.getFlash()==null && param.getVideo()==null) 098 throw new ApplicationException("you have to define video or flash source"); 099 if(param.getFlash()!=null && param.getVideo()!=null) 100 throw new ApplicationException("you can define only one source"); 101 102 103 // get VideoPlayer Tag 104 Tag parent=getParent(); 105 while(parent!=null && !(parent instanceof VideoPlayerJW)) { 106 parent=parent.getParent(); 107 } 108 109 if(parent instanceof VideoPlayerJW) { 110 VideoPlayerJW mail = (VideoPlayerJW)parent; 111 mail.setParam(param); 112 } 113 else { 114 throw new ApplicationException("Wrong Context, tag VideoPlayerParam must be inside a VideoPlayer tag"); 115 } 116 return SKIP_BODY; 117 } 118 119}