Skip to content

Commit

Permalink
Merge branch 'VID-683' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Thies committed Aug 15, 2023
2 parents 2dc67eb + 0bbc493 commit f6e45e9
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 26 deletions.
2 changes: 1 addition & 1 deletion amd/build/videotime.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/videotime.min.js.map

Large diffs are not rendered by default.

44 changes: 39 additions & 5 deletions amd/src/videotime.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ define([

// If resume is present force seek the player to that point.
this.player.on("loaded", () => {
if (!this.instance.resume_playback || this.instance.resume_time <= 0) {
if (!this.instance.resume_playback || !this.instance.resume_time || this.instance.resume_time <= 0) {
return true;
}

Expand Down Expand Up @@ -248,20 +248,47 @@ define([
this.player.on('timeupdate', function(event) {
this.percent = event.percent;
this.currentTime = event.seconds;
Log.debug('VIDEO_TIME timeupdate. Percent: ' + this.percent + '. Current time: ' + this.currentTime);
if (event.seconds === event.duration) {
this.plugins.forEach(plugin => {
if (typeof plugin.setCurrentTime == 'function') {
plugin.getSessions().then(session => {
plugin.setCurrentTime(session.id, event.seconds);
});
}
});
}
}.bind(this));

// Initiate video finish procedure.
this.player.on('ended', this.handleEnd.bind(this));
this.player.on('pause', this.handlePause.bind(this));
};

/**
* Handle pause
*/
VideoTime.prototype.handlePause = function() {
this.plugins.forEach(plugin => {
if (typeof plugin.handlePause == 'function') {
plugin.handlePause();
}
});
};

/**
* Start interval that will periodically record user progress via Ajax.
*/
VideoTime.prototype.handleEnd = function() {
this.playing = false;
Log.debug('VIDEO_TIME ended');

this.playing = false;
Log.debug('VIDEO_TIME ended');
if (this.plugins.length > 2) {
this.plugins.forEach(plugin => {
if (typeof plugin.handleEnd == 'function') {
plugin.handleEnd();
}
});
} else {
// This moved to pro plugin, but left for compatibility.
this.getSession().then(function(session) {
this.setSessionState(session.id, 1).then(() => {
return this.setPercent(session.id, 1);
Expand Down Expand Up @@ -290,12 +317,19 @@ define([
});
}).catch(Notification.exception);
}.bind(this)).catch(Notification.exception);
}
};

/**
* Start interval that will periodically record user progress via Ajax.
*/
VideoTime.prototype.startWatchInterval = function() {
this.plugins.forEach(plugin => {
if (typeof plugin.startWatchInterval == 'function') {
this.watchInterval = true;
plugin.startWatchInterval();
}
});
if (this.watchInterval) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/videojs/amd/build/videotime.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugin/videojs/amd/build/videotime.min.js.map

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions plugin/videojs/amd/src/videotime.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,10 @@ export default class VideoTime extends VideoTimeBase {
this.player.on("play", () => {
if (!this.played) {
if (this.hasPro) {
// Getting a new session on first play.
this.getSession()
.then(() => {
this.view();
this.startWatchInterval();
return true;
})
.catch(Notification.exception);
} else {
// Free version can still mark completion on video time view.
this.view();
this.startWatchInterval();
}
// Free version can still mark completion on video time view.
this.view();
}
return true;
});
Expand Down Expand Up @@ -258,6 +250,7 @@ export default class VideoTime extends VideoTimeBase {

// Initiate video finish procedure.
this.player.on("ended", this.handleEnd.bind(this));
this.player.on("pause", this.handleEnd.bind(this));

// Readjust height when responsive player is resized.
if (this.player.options().responsive) {
Expand Down
2 changes: 1 addition & 1 deletion plugin/vimeo/tests/force_settings_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function setUp() : void {
$this->instancerecord = $this->getDataGenerator()->create_module('videotime', [
'course' => $this->course->id,
'controls' => 0,
'vimeo_url' => 'https://vimeo.com/253989945',
'vimeo_url' => 'https://vimeo.com/347119375',
]);
$this->videotimeinstance = videotime_instance::instance_by_id($this->instancerecord->id);
}
Expand Down
2 changes: 1 addition & 1 deletion tab/block/tests/behat/edit_blocks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Configure videotime block tab
| student | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | vimeo_url | label_mode | section | enabletabs |
| videotime | Video1 | VideoDesc1 | C1 | https://vimeo.com/253989945 | 0 | 1 | 1 |
| videotime | Video1 | VideoDesc1 | C1 | https://vimeo.com/347119375 | 0 | 1 | 1 |
And the following config values are set as admin:
| enabled | 1 | videotimetab_block |
| default | 1 | videotimetab_block |
Expand Down
2 changes: 1 addition & 1 deletion tab/information/tests/behat/custom_label.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Customize videotime information tab label
| student | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | vimeo_url | label_mode | section | enabletabs |
| videotime | Video1 | VideoDesc1 | C1 | https://vimeo.com/253989945 | 0 | 1 | 1 |
| videotime | Video1 | VideoDesc1 | C1 | https://vimeo.com/347119375 | 0 | 1 | 1 |
And the following config values are set as admin:
| enabled | 1 | videotimetab_information |
| default | 1 | videotimetab_information |
Expand Down
2 changes: 1 addition & 1 deletion tab/related/tests/behat/custom_label.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Customize related tab label
| student | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | vimeo_url | label_mode | section | enabletabs |
| videotime | Video1 | VideoDesc1 | C1 | https://vimeo.com/253989945 | 0 | 1 | 1 |
| videotime | Video1 | VideoDesc1 | C1 | https://vimeo.com/347119375 | 0 | 1 | 1 |
And the following config values are set as admin:
| enabled | 1 | videotimetab_related |
| default | 1 | videotimetab_related |
Expand Down
2 changes: 1 addition & 1 deletion tab/related/tests/behat/display_activities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Customize videotime related tab label
| student | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | vimeo_url | label_mode | section | enabletabs |
| videotime | Video1 | VideoDesc1 | C1 | https://vimeo.com/253989945 | 0 | 1 | 1 |
| videotime | Video1 | VideoDesc1 | C1 | https://vimeo.com/347119375 | 0 | 1 | 1 |
And the following "activities" exist:
| activity | name | intro | course | content | section |
| page | Page1 | PageDesc1 | C1 | PageContent1 | 1 |
Expand Down
2 changes: 1 addition & 1 deletion tests/external_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function setUp(): void {
$this->videotimeinstance = $this->getDataGenerator()->create_module('videotime', [
'course' => $this->course->id,
'autoplay' => 1,
'vimeo_embed' => 'https://vimeo.com/253989945',
'vimeo_embed' => 'https://vimeo.com/347119375',
'responsive' => 1
]);
$this->student = $this->getDataGenerator()->create_user();
Expand Down

0 comments on commit f6e45e9

Please sign in to comment.