@Override public void onNewFrame(GSMovie m) { if (!stopSliderAdvance && m != null && timeSlider != null) { timeSlider.setValue(m.time()); } updateTimeInfo(m); }
@Override public void onJump(GSMovie m) { if (timeSlider != null) { timeSlider.setVisible(true); timeSlider.setValue(m.time()); } }
private void updateTimeInfo(GSMovie m) { int totalElapsedSeconds = (int) m.time(); int se = totalElapsedSeconds % 60; totalElapsedSeconds -= se; int totalElapsedMin = totalElapsedSeconds / 60; int me = totalElapsedMin % 60; totalElapsedMin -= me; int totalElapsedHours = totalElapsedMin / 60; int he = totalElapsedHours; totalElapsedSeconds = (int) movieView.getDuration(); int sd = totalElapsedSeconds % 60; totalElapsedSeconds -= sd; totalElapsedMin = totalElapsedSeconds / 60; int md = totalElapsedMin % 60; totalElapsedMin -= md; totalElapsedHours = totalElapsedMin / 60; int hd = totalElapsedHours; displayTime(getTimeString(he, me, se, hd, md, sd)); }
private void addTimeSlider(GSMovie m) { float widthToUse = m.width > GESTURE_AREA_MAX_WIDTH ? GESTURE_AREA_MAX_WIDTH : m.width; Vector3D gestureAreaPosition = gestureArea.getPosition(TransformSpace.LOCAL); timeSlider = new MTSlider( getRenderer(), gestureAreaPosition.x + gestureAreaXPadding, gestureAreaPosition.y + gestureAreaYPadding, widthToUse - gestureAreaXPadding * 2f, // slider width TIME_SLIDER_HEIGHT, 0, 10); // min max values timeSlider.getOuterShape().setFillColor(new MTColor(0, 0, 0, 80)); timeSlider.getOuterShape().setStrokeColor(new MTColor(0, 0, 0, 80)); timeSlider.getKnob().setFillColor(new MTColor(100, 100, 100, 80)); timeSlider.getOuterShape().setStrokeColor(new MTColor(100, 100, 100, 80)); timeSlider .getKnob() .addGestureListener( DragProcessor.class, new IGestureEventListener() { public boolean processGestureEvent(MTGestureEvent ge) { DragEvent de = (DragEvent) ge; switch (de.getId()) { case MTGestureEvent.GESTURE_STARTED: stopSliderAdvance = true; break; case MTGestureEvent.GESTURE_UPDATED: break; case MTGestureEvent.GESTURE_ENDED: if (movieView != null && movieView.getMovie() != null) { float currValue = timeSlider.getValue(); movieView.jump(currValue); } stopSliderAdvance = false; break; default: break; } return false; } }); timeSlider.setValueRange(0, m.duration()); timeSlider .getOuterShape() .addGestureListener( TapProcessor.class, new IGestureEventListener() { @SuppressWarnings("deprecation") public boolean processGestureEvent(MTGestureEvent ge) { TapEvent te = (TapEvent) ge; switch (te.getTapID()) { case TapEvent.BUTTON_DOWN: stopSliderAdvance = true; break; case TapEvent.BUTTON_UP: stopSliderAdvance = false; break; case TapEvent.BUTTON_CLICKED: if (movieView != null && movieView.getMovie() != null) { float currValue = timeSlider.getValue(); movieView.jump(currValue); } stopSliderAdvance = false; break; default: break; } return false; } }); timeSlider.setValue(0); gestureArea.addChild(timeSlider); }