Focus HMI Video Playback

You can play a video you have prepared on Focus HMI panels or a video from the internet.

Playing an Uploaded Video

You can transfer the video to the HMI panel with a USB stick or transfer files via FTP. If you copy your video to the desktop, you can keep it permanently. Otherwise, since the HMI is write protected, it can be deleted from the location where you copy the video.

You need to prepare a script to run the video from within the program. When you run this script with a button, your video will be played through the media player. Create a new script and add the following part to your script.

Process p = Runtime.getRuntime().exec(new String[]{"sudo","mpv","--ontop","--no-border","--geometry=0x0+0+0","/home/focushmi/Desktop/videoplayback.mp4"});
}catch(Exception exp){
javax.swing.JOptionPane.showMessageDialog(null , exp.getMessage());

In this script, /home/focushmi/Desktop/videoplayback.mp4 should be the location of our video.

–ontop : ensures that the video is always on top.

–no-border : plays the video without borders. You can remove this parameter and play with borders.

–geometry=0x0+0+0+0 : 0x0 in the first part here allows us to change the resolution of the video. When we leave 0x0, it opens by default. Then you can determine the position of the video on the screen by entering coordinates in the +0+0 section. If you leave it as +0+0, the video opens in the upper left corner. For example, on 10.1″ panels, our screen resolution is 1024×600. Suppose your video resolution is 600×480. If we change the command to +424+120, our video opens in the lower right corner of the screen. If we change it to +424+0, it opens in the upper right corner.

–fs : opens the video in full screen.

p.waitFor() : if you add this parameter to your script, it will completely cut off the interaction and communication with the background while the video is playing, and freeze the background.

Video playback with Web View object

With Focus HMI‘s web view object you can play a video from a url. For this, your panel must have ethernet connection.

First, create an internal tag of String type in the Communication section and write the url of the video you want to play in the value section. Then select the tag you created in the value section of the Web View object. In this way, the object will start playing the video in the URL.

Leave a Reply