-
Notifications
You must be signed in to change notification settings - Fork 979
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
John Bartos
committed
Mar 5, 2018
1 parent
9de1855
commit e5085f5
Showing
9 changed files
with
239 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* A simple data structure for containing both of the background loading objects. | ||
* loadedMedia is the currently active item which has been put into the background during ad playback. | ||
* loadingMedia is an item which is preloading in the background which may be selected in the future. It is usually the | ||
* next item in the playlist, or the next up item in a recommendations feed. | ||
* @returns {BackgroundMedia} | ||
*/ | ||
/** | ||
* @typedef {Object} BackgroundMedia | ||
* @property {MediaController} loadingItem - The mediaController which has been placed into the background during playback. | ||
* @property {Object} loadingItem - The playlist item loading in the background. | ||
* @property {Promise} loadingMedia - A promise representing the media loading in the background. Resolves with the mediaController. | ||
* @constructor | ||
*/ | ||
export default function BackgroundMedia() { | ||
let loadedMedia = null; | ||
let loadingMedia = null; | ||
|
||
return Object.defineProperties(Object.create(null), { | ||
loadingItem: { | ||
get() { | ||
return loadingMedia ? loadingMedia.item : null; | ||
} | ||
}, | ||
loadingMedia: { | ||
get() { | ||
return loadingMedia ? loadingMedia.loadPromise : null; | ||
}, | ||
set(loadObject) { | ||
loadingMedia = loadObject; | ||
} | ||
}, | ||
loadedMedia: { | ||
get() { | ||
return loadedMedia; | ||
}, | ||
set(mediaController) { | ||
loadedMedia = mediaController; | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.