MediaElement JS Player Component

My problem in vaadin 8.3.2 and mediaelementjs-player version 1.3.3

… 51 more
Caused by: java.lang.NoSuchMethodError: com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.addAttachListener(Lcom/vaadin/server/ClientConnector$AttachListener;)V
at com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.(MediaElementPlayer.java:126)
at com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.(MediaElementPlayer.java:89)
at br.com.j74.componentes.J74VideoUploadBox.getVideo(J74VideoUploadBox.java:137)
at br.com.j74.componentes.J74VideoUploadBox.(J74VideoUploadBox.java:63)
at br.com.j74.listas.PlanilhaListView.(PlanilhaListView.java:39)
… 56 more

help me please…

Hi,
I am trying to use Mediaelementjs Player Addon 1.3.3 in vaadin 8.1.0 getting this exception
java.lang.NoSuchMethodError: com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.addAttachListener(Lcom/vaadin/server/ClientConnector$AttachListener;)V.
This is working with vaadin 7.7.13.
Please can anyone help me with this. How can I use this addon in vaadin 8.1.0…
Thanks…

Ajay Gaddam:

Hi,
I am trying to use Mediaelementjs Player Addon 1.3.3 in vaadin 8.1.0 getting this exception
java.lang.NoSuchMethodError: com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.addAttachListener(Lcom/vaadin/server/ClientConnector$AttachListener;)V.
This is working with vaadin 7.7.13.
Please can anyone help me with this. How can I use this addon in vaadin 8.1.0…
Thanks…

I’m resolve this problem with this code in my pom.xml

<vaadin.version>8.3.2</vaadin.version>


org.vaadin.addons
mediaelementjs-player
1.2.8

Jaime Rodrigues:

Ajay Gaddam:

Hi,
I am trying to use Mediaelementjs Player Addon 1.3.3 in vaadin 8.1.0 getting this exception
java.lang.NoSuchMethodError: com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.addAttachListener(Lcom/vaadin/server/ClientConnector$AttachListener;)V.
This is working with vaadin 7.7.13.
Please can anyone help me with this. How can I use this addon in vaadin 8.1.0…
Thanks…

I’m resolve this problem with this code in my pom.xml

<vaadin.version>8.3.2</vaadin.version>


org.vaadin.addons
mediaelementjs-player
1.2.8

HI jaime,

Thanks for your reply…
I am getting nullpointer exception when I use <vaadin.version>8.3.2</vaadin.version>… org.vaadin.addons mediaelementjs-player 1.2.8…

SEVERE:
java.lang.NullPointerException
at com.vaadin.server.ResourceReference.getURL(ResourceReference.java:51)
at com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.createMediaResource(MediaElementPlayer.java:175)
at com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.setSource(MediaElementPlayer.java:168)
at com.bsa.myvideo.MyUI.init(MyUI.java:55)
at com.vaadin.ui.UI.doInit(UI.java:771)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:218)

Are you also getting the same exception?
Or else please provide me the sample code how you're executing it..
Your help is highly appreciated..!!
Thanks..

Ajay Gaddam:

Jaime Rodrigues:

Ajay Gaddam:

Hi,
I am trying to use Mediaelementjs Player Addon 1.3.3 in vaadin 8.1.0 getting this exception
java.lang.NoSuchMethodError: com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.addAttachListener(Lcom/vaadin/server/ClientConnector$AttachListener;)V.
This is working with vaadin 7.7.13.
Please can anyone help me with this. How can I use this addon in vaadin 8.1.0…
Thanks…

I’m resolve this problem with this code in my pom.xml

<vaadin.version>8.3.2</vaadin.version>


org.vaadin.addons
mediaelementjs-player
1.2.8

HI jaime,

Thanks for your reply…
I am getting nullpointer exception when I use <vaadin.version>8.3.2</vaadin.version>… org.vaadin.addons mediaelementjs-player 1.2.8…

SEVERE:
java.lang.NullPointerException
at com.vaadin.server.ResourceReference.getURL(ResourceReference.java:51)
at com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.createMediaResource(MediaElementPlayer.java:175)
at com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer.setSource(MediaElementPlayer.java:168)
at com.bsa.myvideo.MyUI.init(MyUI.java:55)
at com.vaadin.ui.UI.doInit(UI.java:771)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:218)

Are you also getting the same exception?
Or else please provide me the sample code how you’re executing it…
Your help is highly appreciated…!!
Thanks…

Hi Ajay Gaddam,
i’m used code bellow:
package br.com.j74.componentes;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Handler;
import java.util.logging.LogRecord;

import com.kbdunn.vaadin.addons.mediaelement.MediaElementPlayer;
import com.vaadin.server.Resource;
import com.vaadin.server.Responsive;
import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.ProgressBar;
import com.vaadin.ui.UI;
import com.vaadin.ui.Upload;
import com.vaadin.ui.Upload.FailedEvent;
import com.vaadin.ui.Upload.FailedListener;
import com.vaadin.ui.Upload.ProgressListener;
import com.vaadin.ui.Upload.Receiver;
import com.vaadin.ui.Upload.StartedEvent;
import com.vaadin.ui.Upload.StartedListener;
import com.vaadin.ui.Upload.SucceededEvent;
import com.vaadin.ui.Upload.SucceededListener;
import com.vaadin.ui.Video;
import com.vaadin.ui.themes.ValoTheme;
import com.vaadin.util.FileTypeResolver;

import br.com.j74.controles.PanelContainer;
import br.com.j74.model.ModelObject;
import br.com.j74.utils.Utils;

public class J74VideoUploadBox extends CustomComponent implements Receiver, ProgressListener,
FailedListener, SucceededListener, StartedListener {

private ProgressBar progress = new ProgressBar(0.0f);
private T model;
protected File tempFile;
protected FileOutputStream os;
private PanelContainer container;
private Upload upload;
private J74VideoPlayer videoPlayer;
private Resource resource;

public J74VideoUploadBox(T model, Resource resource) {
	this.model = model;
	this.resource = resource;

	upload = new Upload("", null);
	upload.setButtonCaption("Carregar vídeo");
	upload.setReceiver(this);
	upload.addProgressListener(this);
	upload.addFailedListener(this);
	upload.addSucceededListener(this);
	upload.addStartedListener(this);
	upload.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);

	container = new PanelContainer(new MarginInfo(false,false,false,false));
	container.setSizeFull();
	container.addStyleName("anim-panel");
	Responsive.makeResponsive(container);

	container.addComponent(upload);
	//container.getHeader().setComponentAlignment(upload, Alignment.MIDDLE_CENTER);
	container.getBody().addComponents(getVideo());
	container.getBody().setComponentAlignment(getVideo(), Alignment.MIDDLE_CENTER);

// uploadSucceeded(null);

	progress.setVisible(false);	      
	setCompositionRoot(container);
}            

@Override
public OutputStream receiveUpload(String filename, String mimeType) {
	return Utils.getOutputStream("imagens/" + model.getClass().getSimpleName(), model.getId()+".mp4");
}


@Override
public void updateProgress(long readBytes, long contentLength) {
	progress.setVisible(true);
	if (contentLength == -1)
		progress.setIndeterminate(true);
	else {
		progress.setIndeterminate(false);
		progress.setValue(((float)readBytes) /
				((float)contentLength));
	}
}

@Override
public void uploadSucceeded(SucceededEvent event) {
	progress.setVisible(false);

	AtualizarImagem(model);
}

@Override
public void uploadFailed(FailedEvent event) {
	progress.setVisible(false);
	Utils.showNotification("Falha ao enviar arquivo: " + event.toString());
}

@Override
public void uploadStarted(StartedEvent event) {
	progress.setVisible(true);
}

public PanelContainer getContainer() {
	return container;
}	

public void AtualizarImagem(T model) {
	Resource r = null;
	if (model != null && model.getId()>0) {
		r = Utils.getResource("imagens/" + model.getClass().getSimpleName() + 
				File.separator + model.getId()+".mp4", resource);
		videoPlayer.setSource(r);
		model.setResource(r);
	}
}

public void showUpload(boolean b) {
	upload.setVisible(b);
}

public J74VideoPlayer getVideo() {
	if (videoPlayer == null) {
		// Configure MIME type mappings
		FileTypeResolver.addExtension("ogg", "audio/ogg");
		FileTypeResolver.addExtension("ogv", "video/ogg");
		FileTypeResolver.addExtension("mp4", "video/mp4");
		FileTypeResolver.addExtension("webm", "video/webm");
		FileTypeResolver.addExtension("wmv", "video/x-ms-wmv");
		FileTypeResolver.addExtension("wma", "audio/x-ms-wma");
		FileTypeResolver.addExtension("flv", "video/x-flv");
		FileTypeResolver.addExtension("avi", "video/x-msvideo");
		videoPlayer = new J74VideoPlayer();
		videoPlayer.setResponsive(true);
		videoPlayer.setWidth(640, Unit.PIXELS);
		videoPlayer.setHeight(360, Unit.PIXELS);
	}

	return videoPlayer;
}

public class J74VideoPlayer extends MediaElementPlayer{

	private int CLIPEDURATION = 10000;
	private Timer timerClip = new Timer();
	private TimerTask timerTaskClip;
	
	public J74VideoPlayer() {
		super(MediaElementPlayer.Type.VIDEO);
	}
	
	public void showClipe(int iTime) {
		showClipe(iTime, CLIPEDURATION);
	}
	
	public void showClipe(int iTime, int iDuration) {
        final UI ui = UI.getCurrent();
    	ui.setPollInterval(100);

    	getVideo().setCurrentTime(iTime);
		if(getVideo().isPaused())getVideo().play();
		new java.util.Timer().schedule(
		    new java.util.TimerTask() {
		        @Override
		        public void run() {
    				ui.access(() -> {
						getVideo().pause();
    				});
		        }
		    }, iDuration);		
		}
}

}

I hope to help you!!