Friday, 11 August 2017
Create Thumbnail in Video in Spring and ffmpeg
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.jcodec.api.FrameGrab;
import org.jcodec.api.JCodecException;
import org.jcodec.common.model.Picture;
import org.jcodec.scale.AWTUtil;
public class VideoThumbTaker
{
private String VIDEO_THUMBNAIL_FOLDER_NAME = "thumbnail";
private String UPLOAD_DIRECTORY = "D:/images/"
protected String ffmpegApp;
public VideoThumbTaker(String ffmpegApp)
{
this.ffmpegApp = ffmpegApp;
}
public static String captureImage(String inputFile, int organizationId) throws Exception, IOException, JCodecException
{
String filename = Constants.VIDEO_THUMBNAIL_FILE_PREFIX+System.currentTimeMillis()+".png";
int frameNumber = 1;
Picture picture = FrameGrab.getFrameFromFile(new File(inputFile), frameNumber);
BufferedImage bufferedImage = AWTUtil.toBufferedImage(picture);
ImageIO.write(bufferedImage, "png", new File(UPLOAD_DIRECTORY+"/"+VIDEO_THUMBNAIL_FOLDER_NAME+"/" + filename));
return "o"+organizationId+"/"+VIDEO_THUMBNAIL_FOLDER_NAME+"/" + filename;
}
}
Send Google FCM Push Notification Using Spring Boot
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.esense.touch.dbconstants.NOTIFICATION;
import com.esense.touch.dbconstants.STORY;
import com.esense.touch.dbconstants.USER_NOTIFICATION;
import com.esense.touch.dbconstants.USER_ROLE;
import com.esense.touch.dbconstants.USER_ROLE_DETAIL;
import com.esense.touch.service.NotificationService;
@Service
public class PushNotificationService {
private String AUTH_KEY_FCM="your server auth key";
@Autowired
NotificationService notificationService;
public String sendPushNotification(Rows row)
throws IOException {
String result = "";
URL url = new URL(Constants.API_URL_FCM);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "key=" + AUTH_KEY_FCM);
conn.setRequestProperty("Content-Type", "application/json");
try {
JSONObject json = new JSONObject();
json.put("to", "device Id");
JSONObject info = new JSONObject();
String notificationTitle = "Notification";
info.put("title", notificationTitle);
info.put("body", "Content");
info.put("image","abc/abc.jpg");
json.put("data", info);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(json.toString());
wr.flush();
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
StringBuilder sb = new StringBuilder();
String output;
while ((output = br.readLine()) != null) {
sb.append(output);
}
JSONObject outputobj = new JSONObject(sb.toString());
if(outputobj.get("success").equals(1)){
// success you can write your success code here
}
result = "success";
} catch (Exception e) {
e.printStackTrace();
result = "failure";
}
return result;
}
}
Thursday, 25 May 2017
Context menu design using angularjs
File : app.js
File : index.html
File : style.html
var myApp = angular.module("myApp",[]); myApp.controller( "MainCtrl", [ "$scope", function($scope) { console.log("Main Controller loaded."); $scope.myContextDiv = "
- Item 1
- Item 2
File : index.html
Right Click On the Item!
File : style.html
#contextmenu-node{ position: absolute; background-color: white; border: solid #CCCCCC 1px; } .contextmenu-item{ margin: 0.5em; padding-left: 0.5em; } .contextmenu-item:hover{ background-color: #CCCCCC; cursor: default; }
Subscribe to:
Posts (Atom)
Create Thumbnail in Video in Spring and ffmpeg
import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import org.jcodec.api.Fr...
-
import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import org.jcodec.api.Fr...
-
To continue my series on the power of Zone, I examine yet another powerful and useful way you can use zones to improve your application. I...
-
Recall that the equation of a straight line is given by the equation y = mx +n (1) where m is called the slope of the line. (This m...