Skip to content

Commit 57b1cc9

Browse files
author
dularion
committed
add custom font sizing to player options #878
1 parent d62d268 commit 57b1cc9

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

grails-app/assets/javascripts/streama/directives/streama-video-player-directive.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ angular.module('streama').directive('streamaVideoPlayer', [
4141
$scope.closeVideo = closeVideo;
4242
$scope.clickVideo = clickVideo;
4343
$scope.fullScreen = toggleFullScreen;
44+
$scope.getCustomSubtitleSize = getCustomSubtitleSize;
4445
$scope.next = $scope.options.onNext;
4546
$scope.isInitialized = false;
4647
$scope.isNextVideoShowing = false;
@@ -116,6 +117,8 @@ angular.module('streama').directive('streamaVideoPlayer', [
116117
});
117118

118119
$scope.options.subtitleSize = localStorageService.get('subtitleSize') || 'md';
120+
$scope.options.hasCustomSubtitleSize = localStorageService.get('hasCustomSubtitleSize') || false;
121+
$scope.options.customSubtitleSize = localStorageService.get('customSubtitleSize') || null;
119122
});
120123
}
121124

@@ -196,6 +199,10 @@ angular.module('streama').directive('streamaVideoPlayer', [
196199
$scope.options.onVideoClick();
197200
}
198201

202+
function getCustomSubtitleSize() {
203+
return $scope.options.hasCustomSubtitleSize ? $scope.options.customSubtitleSize : null;
204+
}
205+
199206
function toggleFullScreen() {
200207
var docElm;
201208
var docElmClose = document;
@@ -512,8 +519,12 @@ angular.module('streama').directive('streamaVideoPlayer', [
512519
return;
513520
}
514521

522+
$scope.options.hasCustomSubtitleSize = response.hasCustomSubtitleSize;
523+
$scope.options.customSubtitleSize = response.customSubtitleSize;
515524
$scope.options.subtitleSize = response.subtitleSize;
516525
localStorageService.set('subtitleSize', response.subtitleSize);
526+
localStorageService.set('hasCustomSubtitleSize', response.hasCustomSubtitleSize);
527+
localStorageService.set('customSubtitleSize', response.customSubtitleSize);
517528

518529
if(!_.isEqualBy(response.selectedVideoFile, $scope.options.selectedVideoFile, 'id')){
519530
changeVideoFile(response.selectedVideoFile, video.currentTime);

grails-app/assets/javascripts/streama/templates/modal--playback-options.tpl.htm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ <h4>{{'VIDEO.SUBTITLES' | translate}}</h4>
2424

2525
<div>
2626
<h4>{{'VIDEO.SUBTITLE_SIZE' | translate}}</h4>
27-
<ul class="subtitle-size-picker">
27+
<ul class="subtitle-size-picker" ng-if="!vm.playerOptions.hasCustomSubtitleSize">
2828
<li class="subtitle-size-lg" ng-class="{'active': vm.playerOptions.subtitleSize == 'lg'}" ng-click="vm.changeSubtitleSize('lg')">A</li>
2929
<li class="subtitle-size-md" ng-class="{'active': vm.playerOptions.subtitleSize == 'md'}" ng-click="vm.changeSubtitleSize('md')">A</li>
3030
<li class="subtitle-size-sm" ng-class="{'active': vm.playerOptions.subtitleSize == 'sm'}" ng-click="vm.changeSubtitleSize('sm')">A</li>
3131
</ul>
32+
<div>
33+
<label><input type="checkbox" ng-model="vm.playerOptions.hasCustomSubtitleSize"> Custom Size?</label>
34+
<input ng-if="vm.playerOptions.hasCustomSubtitleSize" class="form-control input-sm" type="text"
35+
placeholder="Custom Font Size (in px)" ng-model="vm.playerOptions.customSubtitleSize">
36+
</div>
3237
</div>
3338
</div>
3439
<div class="col-md-6">

grails-app/assets/javascripts/streama/templates/streama-video-player.tpl.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ <h2 class="seasons-title" ng-click="toggleSelectEpisodes()">
187187
</section>
188188
</div>
189189

190-
<video ng-if="isInitialized" id="video" ng-src="{{options.videoSrc}}" type="{{options.videoType}}" ng-click="clickVideo()" class="subtitle-size-{{options.subtitleSize}}">
190+
<video ng-if="isInitialized" id="video" ng-src="{{options.videoSrc}}" type="{{options.videoType}}" ng-click="clickVideo()" class="subtitle-size-{{options.subtitleSize}} subtitle-size-custom-{{getCustomSubtitleSize()}}">
191191
<track ng-repeat="subtitle in options.subtitles" ng-src="{{subtitle.src}}" kind="subtitles" id="subtitle-{{subtitle.id}}"
192192
srclang="{{subtitle.subtitleSrcLang}}" label="{{subtitle.subtitleLabel}}" src="{{subtitle.src}}">
193193
</video>

grails-app/assets/stylesheets/_player.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ streama-video-player{
1515
video.subtitle-size-sm::cue {
1616
font-size: 0.8em;
1717
}
18+
@for $i from 10 through 60{
19+
video.subtitle-size-custom-#{$i}::cue{
20+
font-size: #{$i}px;
21+
}
22+
}
1823
}
1924

2025
.video-wrapper-inner,

0 commit comments

Comments
 (0)