I create a MediaPlaceholder that renders a videoview / imageview at runtime rather than hiding it.
Depending on the data (for example, Image / URL / Video), the corresponding methods are called. for example: makeSingleImageLoader () / makeUrlLoader (), makeVideoView () .. This is not an effective solution, but it worked for me.
MediaPlaceHolder
public class MediaPlaceholder : LinearLayout
{
Context mContext;
PoppingImageView imageView;
UrlLoader urlLoader;
MultiImageView multiImageView;
BufferingSurfaceView bufferingSurfaceView;
public MediaPlaceholder(Context context) : base(context) {
init(context);
}
public MediaPlaceholder(Context context, IAttributeSet attrs) : base(context, attrs) {
init(context);
}
public MediaPlaceholder(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr) {
init(context);
}
void init(Context context) {
mContext = context;
}
void prepareView() {
this.RemoveAllViews ();
}
public void makeUrlLoaderView(String url) {
prepareView();
if (urlLoader == null) {
urlLoader = new UrlLoader(mContext);
}
urlLoader.loadPreview(url);
AddView(urlLoader, new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
}
public void makeSingleImageView(IMedia imageUrl) {
prepareView();
if (imageView == null) {
imageView = new PoppingImageView(mContext);
}
imageView.setDataresources(imageUrl, 0).enableDialogPopup(true);
AddView(imageView, new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
}
public void makeVideoView(String videoUrl, int position) {
prepareView();
if (bufferingSurfaceView == null) {
bufferingSurfaceView = new BufferingSurfaceView(mContext);
}
bufferingSurfaceView.setMediaSource(videoUrl,position);
AddView(bufferingSurfaceView, new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
}
}
source
share