/** * 实现将初始日期时间2012年07月02日 16:45 拆分成年 月 日 时 分 秒,并赋值给calendar * * @param initDateTime 初始日期时间值 字符串型 * @return Calendar */ private Calendar getCalendarByInintData(String initDateTime) { Calendar calendar = Calendar.getInstance(); // 将初始日期时间2012年07月02日 16:45 拆分成年 月 日 时 分 秒 String date = spliteString(initDateTime, "-", "index", "front"); // 日期 String yearStr = spliteString(date, "-", "index", "front"); // 年份 String monthAndDay = spliteString(date, "-", "index", "back"); // 月日 String monthStr = spliteString(monthAndDay, "-", "index", "front"); // 月 String dayStr = spliteString(monthAndDay, "-", "index", "back"); // 日 int currentYear = 2016; if (!StringUtil.isNullOrEmpty(yearStr)) { currentYear = Integer.valueOf(yearStr.trim()).intValue(); } int currentMonth = 0; if (!StringUtil.isNullOrEmpty(monthStr)) { currentMonth = Integer.valueOf(monthStr.trim()).intValue() - 1; } int currentDay = 0; if (!StringUtil.isNullOrEmpty(dayStr)) { currentDay = Integer.valueOf(dayStr.trim()).intValue(); } calendar.set(currentYear, currentMonth, currentDay); return calendar; }
public void uploadFile() { if (StringUtil.isNullOrEmpty(path)) { Toast.makeText(this, R.string.video_error, Toast.LENGTH_SHORT).show(); return; } // Bitmap bm = FileUtils.getSmallBitmap(path); // String cameraImagePath = FileUtils.saveBitToSD(bm, System.currentTimeMillis() + // ".jpg"); File f = new File(path); Map<String, File> files = new HashMap<String, File>(); files.put("file", f); Map<String, String> params = new HashMap<String, String>(); CommonUtil.addPutUploadFileRequest( this, InternetURL.UPLOAD_FILE_URL, // http://115.29.200.169/api/test/uploadfile files, params, new Response.Listener<String>() { @Override public void onResponse(String s) { if (StringUtil.isJson(s)) { try { JSONObject jo = new JSONObject(s); String code1 = jo.getString("code"); if (Integer.parseInt(code1) == 200) { videoUrl = jo.getString("url"); publishRun(videoUrl); } } catch (JSONException e) { if (pd != null && pd.isShowing()) { pd.dismiss(); } e.printStackTrace(); } } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { if (pd != null && pd.isShowing()) { pd.dismiss(); } } }, null); }
private void prepare(Surface surface) { try { if (!StringUtil.isNullOrEmpty(path) && mediaPlayer != null) { mediaPlayer.reset(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); // 设置需要播放的视频 mediaPlayer.setDataSource(path); // 把视频画面输出到Surface mediaPlayer.setSurface(surface); mediaPlayer.setLooping(true); mediaPlayer.prepare(); mediaPlayer.seekTo(0); } } catch (Exception e) { } }