Skip to content

Commit

Permalink
Add save state
Browse files Browse the repository at this point in the history
- add save state for transcripts
  • Loading branch information
dorosh committed Jan 26, 2017
1 parent 0c46e61 commit bbf8643
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions video_xblock/static/js/player_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var saveState = function() {
var player = this;
var new_state = {
volume: player.volume(),
currentTime: player.ended()? 0 : Math.floor(player.currentTime()),
currentTime: player.ended()? 0 : player.currentTime(),
playbackRate: player.playbackRate(),
muted: player.muted(),
transcriptsEnabled: player.transcriptsEnabled,
Expand Down Expand Up @@ -114,7 +114,7 @@ var saveProgressToLocalStore = function() {
playbackProgress = '{}';
}
playbackProgress = JSON.parse(playbackProgress);
playbackProgress['{{ video_player_id }}'] = player.ended() ? 0 : Math.floor(player.currentTime());
playbackProgress['{{ video_player_id }}'] = player.ended() ? 0 : player.currentTime();
localStorage.setItem('playbackProgress',JSON.stringify(playbackProgress));
};

Expand Down
4 changes: 4 additions & 0 deletions video_xblock/static/js/videojs-transcript.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ domReady(function() {
showTitle: false,
followPlayerTrack: true
});
transcript.el().addEventListener('click', function() {
player_.trigger('transcriptstatechanged');
});

// Show or hide the transcripts block depending on the transcript state
if (!player_.transcriptsEnabled) {
transcriptContainer.className += ' is-hidden';
Expand Down
4 changes: 2 additions & 2 deletions video_xblock/video_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import requests

from xblock.core import XBlock
from xblock.fields import Scope, Boolean, Integer, Float, String
from xblock.fields import Scope, Boolean, Float, String
from xblock.fragment import Fragment
from xblock.validation import ValidationMessage
from xblockutils.studio_editable import StudioEditableXBlockMixin
Expand Down Expand Up @@ -149,7 +149,7 @@ class VideoXBlock(TranscriptsMixin, StudioEditableXBlockMixin, XBlock):
)

# Playback state fields
current_time = Integer(
current_time = Float(
default=0,
scope=Scope.user_state,
help='Seconds played back after the start'
Expand Down

0 comments on commit bbf8643

Please sign in to comment.