Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function TVButton(el, adjacent_buttons, parent) {
this.not_handle_mouse = this.attributes['not_handle_mouse']; // не реагировать на движения мышкой
this.not_hover_on_bound = this.attributes['not_hover_on_bound']; // не разрешать наводить на элементы выходящие за границу экрана на столько пикселей
this.hover_on_bound = this.attributes['hover_on_bound']; // разрешать наводить на элементы выходящие за границу экрана
this.allow_dbl_click = this.attributes['allow_dbl_click'] && this.attributes['allow_dbl_click'] == 'true' ? true : false; // разрешать двойное нажатие
if (this.attributes['btn']) {
var s = this.attributes['btn'].split(',');
if (s[0]) this.up = s[0].trim();
Expand Down Expand Up @@ -263,8 +264,10 @@ TVButton.prototype.onmouseout = function() {
TVButton.prototype.onmouseclick = function(event) {
if (this.disabled) return;
if (!this.isMouseOnly()) {
var act_btn = this.adjacent_buttons._act_btn;
if (act_btn == this) return; // предотвращаем двойное нажатие
if (!this.allow_dbl_click) {
var act_btn = this.adjacent_buttons._act_btn;
if (act_btn == this) return; // предотвращаем двойное нажатие
}
for (var btn in this.adjacent_buttons) {
if (this.adjacent_buttons[btn]) TV.removeClass(this.adjacent_buttons[btn].el, TVButton.act_class);
};
Expand Down
29 changes: 2 additions & 27 deletions js/components/grid_slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@ TVComponents.GridSlider.prototype.onready = function() {
TVComponents.GridSlider.prototype._movie = function(is_first) {
if (is_first && this.start_position <= 0) return;
if (!is_first && this.start_position + this.count >= this.data.length) return;
this.buttons._hover_btn && this.buttons._hover_btn.onmouseout();

var max = 0, curr = null;
var max = 0;
for (var i=0; i < (this.is_vertical ? this.box_x : this.box_y); i++) {
var el = is_first ? this.buttons[this.first_btn_id].el.previousElementSibling : this.buttons[this.last_btn_id].el.nextElementSibling;
// ищем позицию текущей кнопки
var btn = this.is_vertical ? this.buttons[this.box[is_first ? 0 : this.box_y-1][i]] : this.buttons[this.box[i][is_first ? 0 : this.box_x-1]];
if (btn && this.buttons._hover_btn && this.buttons._hover_btn.id == btn.id) curr = i;
// удаляем вышедшую за видимые границы линию
btn = this.is_vertical ? this.buttons[this.box[is_first ? this.box_y-1: 0][i]] : this.buttons[this.box[i][is_first ? this.box_x-1: 0]];
var btn = this.is_vertical ? this.buttons[this.box[is_first ? this.box_y-1: 0][i]] : this.buttons[this.box[i][is_first ? this.box_x-1: 0]];
if (btn) {
btn.el.removeAttribute('data-type');
btn.remove();
Expand Down Expand Up @@ -63,27 +59,6 @@ TVComponents.GridSlider.prototype._movie = function(is_first) {
this.container_el.style.left = pos + 'px';
}

// фиксируем переход
/*if (curr != null) {
if (this.is_vertical) {
var x = curr;
var y = is_first ? 0 : this.box_y-1;
do {
var btn = this.buttons[this.box[y][x]];
x -= 1;
} while (!btn);
this.buttons._hover_btn[is_first ? 'up' : 'down'] = btn.id;
} else {
var x = is_first ? 0 : this.box_x-1;
var y = curr;
do {
var btn = this.buttons[this.box[y][x]];
y -= 1;
} while (!btn);
this.buttons._hover_btn[is_first ? 'left' : 'right'] = btn.id;
}
}*/

this.updateNavButtons();
};

Expand Down
11 changes: 9 additions & 2 deletions js/components/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ TVComponents.Player.prototype.btnProcessSeek = function(direction) {
this._seek_direction = null;
this._seek_step = null;
TV.hide('[data-id="player_loader"]', this.el);
}.bind(this), 700);
}.bind(this), 1000);
};

// видео объект получил метаданные
Expand Down Expand Up @@ -282,6 +282,12 @@ TVComponents.Player.prototype.onvideobuffering = function(val) {
// прогресс проигрывания
TVComponents.Player.prototype.onvideoprogress = function(time) {
TV.log('onvideoprogress', time);
if (this.video._tizen_stream_completed) {
this.video._tizen_stream_completed = false;
this.stop();
this.onend && this.onend();
return;
}
if (this.buffering) this.onvideobuffering(100);
if (this._show_seek) this.hideSeek();
if (this.state == 'stop') return;
Expand All @@ -290,6 +296,7 @@ TVComponents.Player.prototype.onvideoprogress = function(time) {
this._last_videoprogress_time = time;
TV.hide('[data-id="player_error"]', this.el);
if (this.onprogress && this.onprogress(time / 1000) === false) return;
if (!this._videoready) this.onvideoready(); // в Netcast не всегда при старте плеера срабатывает onvideoready
if (this.data.seek && !this._data_seek) {
TV.log('Auto seek to', this.data.seek, ' the state is', this.state);
this._data_seek = true;
Expand All @@ -312,7 +319,7 @@ TVComponents.Player.prototype.onvideoprogress = function(time) {
this.curr_time = (this.data.base_time || 0) + time / 1000;
if (!this.isLive()) {
this.updateTimeline();
var end_time = (TV.platform.isLG || TV.platform.isWebOs) ? this.duration-0.99 : this.duration;
var end_time = (TV.platform.isLG || TV.platform.isWebOs || TV.platform.isTizen) ? this.duration-0.99 : this.duration;
if (this.curr_time > 0 && this.duration > 0 && this.curr_time >= end_time) {
TV.log('force stop', this.state);
this.stop();
Expand Down
31 changes: 18 additions & 13 deletions js/components/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,29 @@ TVComponents.Slider.prototype.oncursor = function(side, is_mouse) {
TVComponent.prototype.oncursor.call(this, side);
};

TVComponents.Slider.prototype.moveTo = function(el) {
var scrollbar = TV.el('[data-type="slider-scrollbar"]', this.el);
TVComponents.Slider.prototype.moveTo = function(index) {
if (index == this.start_position || index > this.data.length - 1) return;

var scrollbar = TV.el('[data-type="slider-scrollbar"]', this.el),
old_movie_debounce = this.movie_debounce,
steps_count = Math.abs(index - this.start_position);

// выключаем плавную прокрутку
this.container_el.style.transition = "none";
this.container_el.style.webkitTransition = "none";
if (scrollbar) {
scrollbar.style.transition = "none";
scrollbar.style.webkitTransition = "none";
}

// выключаем запрет быстрого пролистывания
this.movie_debounce = null;

// листаем, пока el не станет первым
for (var i = 0; i<=this.data.length-1; i++) {
if (this.buttons[this.first_btn_id].el != el) this._movie(false);
else break;
for (var i = 0; i < steps_count; i++) {
this._movie(index < this.start_position);
}

this.setScrollbar();
// вызываем repaint у браузера перед тем, как включить transition
this.container_el.offsetHeight;
Expand All @@ -259,20 +268,16 @@ TVComponents.Slider.prototype.moveTo = function(el) {
}
this.container_el.style.transition = "all 0.3s ease-in-out";
this.container_el.style.webkitTransition = "all 0.3s ease-in-out";
// включаем запрет быстрого пролистывания
this.movie_debounce = old_movie_debounce;
};

TVComponents.Slider.prototype.moveToCenter = function() {
if (this.data.length < 2) return;
var center_ind = Math.floor(this.data.length/2) - 1,
curr_ind = 0;

for (var btn in this.buttons) {
if (curr_ind == center_ind) {
this.moveTo(btn.el);
break;
}
curr_ind++;
}

this.moveTo(center_ind);
};

// is_first - движение влево/вверх
Expand Down
7 changes: 7 additions & 0 deletions js/external/hls.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ TV.log = function() {
s += TV.dump_props(arguments[i])+' ';
}
if (TV.platform.isSamsung && TV.platform.isEmulator) {
alert(s);
console.log(s);
} else if (console && console.log) {
console.log.apply(console, arguments);
}
Expand Down
3 changes: 2 additions & 1 deletion js/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function TVPage(app, name) {
'key_green_on_popup', // признак срабатывания зеленой кнопки при открытых попапах
'key_blue_on_popup', // признак срабатывания синей кнопки при открытых попапах
'no_footer', // не показывать футер
'no_header' // не показывать хидер
'no_header', // не показывать хидер
'allow_dbl_click' // разрешить двойное нажатие
];
for (var i in this.props) {
this[this.props[i]] = this.attributes[this.props[i]] || '';
Expand Down
22 changes: 19 additions & 3 deletions js/player_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TV.PlayerWrapper = function(el) {
this.onerror = null; // ошибка воспроизведения
this.video_window_w = null; // размер видео-окна. используется для Samsung
this.video_window_h = null;
this._tizen_stream_completed = false; // флаг для tizen native-эвента и вызова onend

this.el = TV.el(el);
if (this.el) TV.PlayerWrapper.video_el = this.el;
Expand Down Expand Up @@ -88,6 +89,8 @@ TV.PlayerWrapper.prototype.attachCallbacks = function() {
}.bind(this),
onstreamcompleted: function() {
TV.log("Tizen stream completed");
this._tizen_stream_completed = true;
this.onprogress && this.onprogress(this._curr_time);
}.bind(this),
onerror: function(error) {
this.onerror && this.onerror(error);
Expand Down Expand Up @@ -410,12 +413,25 @@ TV.PlayerWrapper.prototype.play = function() {
this.el.play(1);
TV.log('this.el.playTime after start', this.el.playTime);
} else if (TV.platform.isBrowser) {
this.el.src = this._getUrl();
this.el.load();
this.el.play();
playForBrowser(this.el, this._getUrl());
}
};

function playForBrowser(video, url) {
if (Hls && Hls.isSupported()) {
var hls = new Hls();
hls.loadSource(url);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
video.play();
});
} else {
video.src = url;
video.load();
video.play();
}
}

TV.PlayerWrapper.prototype.pause = function() {
if (TV.platform.isTizen) {
webapis.avplay.pause();
Expand Down