mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
refactor of MediaPlayer.js
This commit is contained in:
parent
31bd531453
commit
6d7d473fcf
1 changed files with 317 additions and 313 deletions
|
@ -1,13 +1,16 @@
|
|||
var MediaPlayer = {
|
||||
var MediaPlayer = (function (document) {
|
||||
|
||||
testableAudioElement: document.createElement('audio'),
|
||||
testableVideoElement: document.createElement('video'),
|
||||
var testableAudioElement = document.createElement('audio');
|
||||
var testableVideoElement = document.createElement('video');
|
||||
var currentMediaElement;
|
||||
|
||||
return {
|
||||
|
||||
canPlay: function (item) {
|
||||
|
||||
if (item.MediaType === "Video") {
|
||||
|
||||
var media = MediaPlayer.testableVideoElement;
|
||||
var media = testableVideoElement;
|
||||
|
||||
if (media.canPlayType) {
|
||||
|
||||
|
@ -19,7 +22,7 @@
|
|||
|
||||
if (item.MediaType === "Audio") {
|
||||
|
||||
var media = MediaPlayer.testableAudioElement;
|
||||
var media = testableAudioElement;
|
||||
|
||||
if (media.canPlayType) {
|
||||
|
||||
|
@ -56,7 +59,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
MediaPlayer.mediaElement = mediaElement;
|
||||
currentMediaElement = mediaElement;
|
||||
|
||||
var nowPlayingBar = $('#nowPlayingBar').show();
|
||||
|
||||
|
@ -170,7 +173,7 @@
|
|||
|
||||
playVideo: function (items, startPosition) {
|
||||
//stop/kill videoJS
|
||||
if (MediaPlayer.mediaElement) MediaPlayer.stop();
|
||||
if (currentMediaElement) MediaPlayer.stop();
|
||||
|
||||
var item = items[0];
|
||||
|
||||
|
@ -294,7 +297,7 @@
|
|||
|
||||
stop: function () {
|
||||
|
||||
var elem = MediaPlayer.mediaElement;
|
||||
var elem = currentMediaElement;
|
||||
|
||||
//check if it's a video using VideoJS
|
||||
if ($(elem).hasClass("vjs-tech")) {
|
||||
|
@ -335,11 +338,11 @@
|
|||
|
||||
$('#nowPlayingBar').hide();
|
||||
|
||||
MediaPlayer.mediaElement = null;
|
||||
currentMediaElement = null;
|
||||
},
|
||||
|
||||
isPlaying: function () {
|
||||
return MediaPlayer.mediaElement;
|
||||
return currentMediaElement;
|
||||
},
|
||||
|
||||
updateProgress: function () {
|
||||
|
@ -357,5 +360,6 @@
|
|||
ApiClient.reportPlaybackProgress(Dashboard.getCurrentUserId(), item_id, positionTicks);
|
||||
}, 30000);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
})(document);
|
Loading…
Add table
Add a link
Reference in a new issue