Skip to content
Permalink
Browse files

Add Stop method to VideoPlayer

Change-Id: I09bec5aca529b51746d3b56a5f2c4c9a4bcf5eea
  • Loading branch information...
kuan9611 authored and ewpatton committed Mar 6, 2019
1 parent 0d3098c commit b2d4a63c3db4a652c173a381ab52191eaa88f5d3
@@ -1397,10 +1397,15 @@ private static int upgradeVideoPlayerProperties(Map<String, JSONValue> component
srcCompVersion = 4;
}
if (srcCompVersion < 5) {
// The Volume property (setter only) was created.
// No properties need to be modified to upgrade to version 4.
srcCompVersion = 5;
}
// The Volume property (setter only) was created.
// No properties need to be modified to upgrade to version 5.
srcCompVersion = 5;
}
if (srcCompVersion < 6) {
// The Stop method was created.
// No properties need to be modified to upgrade to version 6.
srcCompVersion = 6;
}
return srcCompVersion;
}

@@ -2509,7 +2509,10 @@ Blockly.Versioning.AllUpgradeMaps =
4: "noUpgrade",

// AI2: The Volume property (setter only) was added to the VideoPlayer.
5: "noUpgrade"
5: "noUpgrade",

// AI2: Stop method was added to the VideoPlayer.
6: "noUpgrade"

}, // End VideoPlayer upgraders

@@ -444,10 +444,12 @@ private YaVersion() {
// - NOTIFIER_COMPONENT_VERSION was incremented to 6
// For YOUNG_ANDROID_VERSION 178:
// - CLOCK_COMPONENT_VERSION was incremented to 4
// For YOUNG_ANDROID_VERISON 179:
// For YOUNG_ANDROID_VERSION 179:
// - BLOCKS_LANGUAGE_VERSION was incremented to 24
// For YOUNG_ANDROID_VERSION 180:
// - VIDEOPLAYER_COMPONENT_VERSION was incremented to 6

public static final int YOUNG_ANDROID_VERSION = 179;
public static final int YOUNG_ANDROID_VERSION = 180;

// ............................... Blocks Language Version Number ...............................

@@ -1156,7 +1158,9 @@ private YaVersion() {
// - The FullScreen property was added to the VideoPlayer.
// For VIDEOPLAYER_COMPONENT_VERSION 5:
// - The Volume property (setter only) was added to the VideoPlayer.
public static final int VIDEOPLAYER_COMPONENT_VERSION = 5;
// For VIDEOPLAYER_COMPONENT_VERSION 6:
// - The Stop method was added to the VideoPlayer.
public static final int VIDEOPLAYER_COMPONENT_VERSION = 6;

public static final int VOTING_COMPONENT_VERSION = 1;

@@ -283,6 +283,18 @@ public void Pause() {
}
}

@SimpleFunction(
description = "Resets to start of video and pauses it if video was playing.")
public void Stop() {
Log.i("VideoPlayer", "Calling Stop");
// Call start() to ensure frame shown is updated;
// Otherwise stopping while a video is on pause will not refresh its view
// until video is started again.
Start();
SeekTo(0);
Pause();
}

@SimpleFunction(
description = "Seeks to the requested time (specified in milliseconds) in the video. " +
"If the video is paused, the frame shown will not be updated by the seek. " +
@@ -103,50 +103,27 @@ public FullScreenVideoUtil(Form form, Handler handler) {
mForm = form;
mHandler = handler;

if (SdkLevel.getLevel() > SdkLevel.LEVEL_DONUT) {
mFullScreenVideoDialog = new Dialog(mForm,
R.style.Theme_NoTitleBar_Fullscreen) {
public void onBackPressed() {
// Allows the user to force exiting full-screen.
Bundle values = new Bundle();
values.putInt(VIDEOPLAYER_POSITION,
mFullScreenVideoView.getCurrentPosition());
values.putBoolean(VIDEOPLAYER_PLAYING,
mFullScreenVideoView.isPlaying());
values.putString(VIDEOPLAYER_SOURCE,
mFullScreenVideoBundle.getString(VIDEOPLAYER_SOURCE));
mFullScreenPlayer.fullScreenKilled(values);
super.onBackPressed();
}

public void onStart() {
super.onStart();
// Prepare the Dialog media.
startDialog();
}
};
} else {
mFullScreenVideoDialog = new Dialog(mForm,
R.style.Theme_NoTitleBar_Fullscreen) {
protected void onStop() {
Bundle values = new Bundle();
values.putInt(VIDEOPLAYER_POSITION,
mFullScreenVideoView.getCurrentPosition());
values.putBoolean(VIDEOPLAYER_PLAYING,
mFullScreenVideoView.isPlaying());
values.putString(VIDEOPLAYER_SOURCE,
mFullScreenVideoBundle.getString(VIDEOPLAYER_SOURCE));
mFullScreenPlayer.fullScreenKilled(values);
super.onStop();
}

public void onStart() {
super.onStart();
// Prepare the Dialog media.
startDialog();
}
};
}
mFullScreenVideoDialog = new Dialog(mForm,
R.style.Theme_NoTitleBar_Fullscreen) {
public void onBackPressed() {
// Allows the user to force exiting full-screen.
Bundle values = new Bundle();
values.putInt(VIDEOPLAYER_POSITION,
mFullScreenVideoView.getCurrentPosition());
values.putBoolean(VIDEOPLAYER_PLAYING,
mFullScreenVideoView.isPlaying());
values.putString(VIDEOPLAYER_SOURCE,
mFullScreenVideoBundle.getString(VIDEOPLAYER_SOURCE));
mFullScreenPlayer.fullScreenKilled(values);
super.onBackPressed();
}

public void onStart() {
super.onStart();
// Prepare the Dialog media.
startDialog();
}
};
}

/**

0 comments on commit b2d4a63

Please sign in to comment.
You can’t perform that action at this time.