diff --git a/src/app/listen/listen.js b/src/app/listen/listen.js index e2a75124..29d96234 100644 --- a/src/app/listen/listen.js +++ b/src/app/listen/listen.js @@ -81,6 +81,8 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) // set up some dummy objects for use later $scope.jumpToHide = true; + $scope.startOffsetAbsolute = null; + $scope.endOffsetAbsolute = null; $scope.model = { audioElement: { volume: null, @@ -165,6 +167,14 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) throw "The provided sample rate for the Media json must be a number!"; } + + var // moment works by reference - need to parse the date twice - sigh + absoluteStartChunk = moment($scope.model.media.datetime).add('s', parseFloat($scope.model.media.startOffset)), + absoluteEndChunk = moment($scope.model.media.datetime).add('s', parseFloat($scope.model.media.endOffset)); + + $scope.startOffsetAbsolute = absoluteStartChunk.format("HH:mm:ss"); + $scope.endOffsetAbsolute = absoluteEndChunk.format("HH:mm:ss"); + }, function mediaGetFailure() { console.error("retrieval of media json failed"); @@ -312,19 +322,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) }; - $scope.startOffsetChunk = function () { - if (!$scope.model.media) { - return undefined; - } - return baw.secondsToDurationFormat($scope.model.media.startOffset); - }; - $scope.endOffsetChunk = function () { - if (!$scope.model.media) { - return undefined; - } - return baw.secondsToDurationFormat($scope.model.media.endOffset); - }; $scope.durationChunk = function () { if (!$scope.model.media) { @@ -356,6 +354,23 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) return baw.secondsToDurationFormat(start + offset); }; + $scope.currentOffsetAbsolute = function () { + var chunkOffset = 0; + if ($scope.model.audioElement) { + chunkOffset = $scope.model.audioElement.position; + } + + if (!$scope.model.media) { + return undefined; + } + + var baseDate = moment($scope.model.media.datetime), + recordingOffset = parseFloat($scope.model.media.startOffset), + absolute = baseDate.add('s', recordingOffset + chunkOffset); + + return absolute.format("HH:mm:ss.SSS"); + }; + $scope.absoluteDateChunkStart = function () { if (!$scope.model.media || !$scope.model.audioRecording) { return undefined; @@ -366,6 +381,10 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) return offset; }; + $scope.jumpToMinuteAbsolute = function jumpToMinuteCalculation() { + return moment($scope.model.media.datetime).add('m', $scope.jumpToMinute).format("HH:mm:ss"); + }; + $scope.previousEnabled = false; $scope.nextEnabled = false; @@ -384,11 +403,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) if (linkType === "previous") { var lowerBound = ($routeParams.start - stepBy); - if ($routeParams.start > 0) { - $scope.previousEnabled = true; - } else { - $scope.previousEnabled = false; - } + $scope.previousEnabled = $routeParams.start > 0; if (lowerBound === 0) { baseLink.end = lowerBound + stepBy; @@ -419,11 +434,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) end: (($routeParams.end + stepBy < maxEnd) ? $routeParams.end + stepBy : maxEnd) }); - if ($routeParams.end < $scope.model.audioRecording.durationSeconds - constants.listen.minAudioDurationSeconds) { - $scope.nextEnabled = true; - } else { - $scope.nextEnabled = false; - } + $scope.nextEnabled = $routeParams.end < $scope.model.audioRecording.durationSeconds - constants.listen.minAudioDurationSeconds; return uriNext; } diff --git a/src/app/listen/listen.tpl.html b/src/app/listen/listen.tpl.html index dda07246..fe63fc24 100644 --- a/src/app/listen/listen.tpl.html +++ b/src/app/listen/listen.tpl.html @@ -37,7 +37,7 @@