|
|
@ -546,16 +546,17 @@ export class AppMediaPlaybackController { |
|
|
|
this.setMedia(media, message); |
|
|
|
this.setMedia(media, message); |
|
|
|
|
|
|
|
|
|
|
|
const verify = (element: MediaItem) => element.mid === mid && element.peerId === peerId; |
|
|
|
const verify = (element: MediaItem) => element.mid === mid && element.peerId === peerId; |
|
|
|
const current = this.listLoader.getCurrent(); |
|
|
|
const listLoader = this.listLoader; |
|
|
|
|
|
|
|
const current = listLoader.getCurrent(); |
|
|
|
if(!current || !verify(current)) { |
|
|
|
if(!current || !verify(current)) { |
|
|
|
const previous = this.listLoader.getPrevious(); |
|
|
|
const previous = listLoader.getPrevious(); |
|
|
|
|
|
|
|
|
|
|
|
let idx = previous.findIndex(verify); |
|
|
|
let idx = previous.findIndex(verify); |
|
|
|
let jumpLength: number; |
|
|
|
let jumpLength: number; |
|
|
|
if(idx !== -1) { |
|
|
|
if(idx !== -1) { |
|
|
|
jumpLength = -(previous.length - idx); |
|
|
|
jumpLength = -(previous.length - idx); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
idx = this.listLoader.getNext().findIndex(verify); |
|
|
|
idx = listLoader.getNext().findIndex(verify); |
|
|
|
if(idx !== -1) { |
|
|
|
if(idx !== -1) { |
|
|
|
jumpLength = idx + 1; |
|
|
|
jumpLength = idx + 1; |
|
|
|
} |
|
|
|
} |
|
|
@ -605,9 +606,10 @@ export class AppMediaPlaybackController { |
|
|
|
|
|
|
|
|
|
|
|
//console.log('on media end');
|
|
|
|
//console.log('on media end');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const listLoader = this.listLoader; |
|
|
|
if(this.lockedSwitchers || |
|
|
|
if(this.lockedSwitchers || |
|
|
|
(!this.round && this.listLoader.current && !this.listLoader.next.length) || |
|
|
|
(!this.round && listLoader.current && !listLoader.next.length) || |
|
|
|
!this.listLoader.getNext().length || |
|
|
|
!listLoader.getNext().length || |
|
|
|
!this.next()) { |
|
|
|
!this.next()) { |
|
|
|
this.stop(); |
|
|
|
this.stop(); |
|
|
|
rootScope.dispatchEvent('media_stop'); |
|
|
|
rootScope.dispatchEvent('media_stop'); |
|
|
@ -704,14 +706,15 @@ export class AppMediaPlaybackController { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public go = (length: number, dispatchJump?: boolean) => { |
|
|
|
public go = (length: number, dispatchJump?: boolean) => { |
|
|
|
if(this.lockedSwitchers) { |
|
|
|
const listLoader = this.listLoader; |
|
|
|
|
|
|
|
if(this.lockedSwitchers || !listLoader) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(this.playingMediaType === 'audio') { |
|
|
|
if(this.playingMediaType === 'audio') { |
|
|
|
return this.listLoader.goRound(length, dispatchJump); |
|
|
|
return listLoader.goRound(length, dispatchJump); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return this.listLoader.go(length, dispatchJump); |
|
|
|
return listLoader.go(length, dispatchJump); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -772,8 +775,9 @@ export class AppMediaPlaybackController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public setTargets(current: MediaItem, prev?: MediaItem[], next?: MediaItem[]) { |
|
|
|
public setTargets(current: MediaItem, prev?: MediaItem[], next?: MediaItem[]) { |
|
|
|
if(!this.listLoader) { |
|
|
|
let listLoader = this.listLoader; |
|
|
|
this.listLoader = new SearchListLoader({ |
|
|
|
if(!listLoader) { |
|
|
|
|
|
|
|
listLoader = this.listLoader = new SearchListLoader({ |
|
|
|
loadCount: 10, |
|
|
|
loadCount: 10, |
|
|
|
loadWhenLeft: 5, |
|
|
|
loadWhenLeft: 5, |
|
|
|
processItem: (message: Message.message) => { |
|
|
|
processItem: (message: Message.message) => { |
|
|
@ -789,21 +793,21 @@ export class AppMediaPlaybackController { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.listLoader.reset(); |
|
|
|
listLoader.reset(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const reverse = this.searchContext.folderId !== undefined ? false : true; |
|
|
|
const reverse = this.searchContext.folderId !== undefined ? false : true; |
|
|
|
if(prev) { |
|
|
|
if(prev) { |
|
|
|
this.listLoader.setTargets(prev, next, reverse); |
|
|
|
listLoader.setTargets(prev, next, reverse); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.listLoader.reverse = reverse; |
|
|
|
listLoader.reverse = reverse; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.listLoader.setSearchContext(this.searchContext); |
|
|
|
listLoader.setSearchContext(this.searchContext); |
|
|
|
this.listLoader.current = current; |
|
|
|
listLoader.current = current; |
|
|
|
|
|
|
|
|
|
|
|
this.listLoader.load(true); |
|
|
|
listLoader.load(true); |
|
|
|
this.listLoader.load(false); |
|
|
|
listLoader.load(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private getPlaybackMediaTypeFromMessage(message: Message.message) { |
|
|
|
private getPlaybackMediaTypeFromMessage(message: Message.message) { |
|
|
@ -861,10 +865,17 @@ export class AppMediaPlaybackController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(media && this.playingMedia === media) { |
|
|
|
// If it's still not cleaned
|
|
|
|
this.stop(); |
|
|
|
if(this.playingMedia === media) { |
|
|
|
|
|
|
|
this.playingMedia = undefined; |
|
|
|
|
|
|
|
this.playingMediaType = undefined; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// I don't remember what it was for
|
|
|
|
|
|
|
|
// if(media && this.playingMedia === media) {
|
|
|
|
|
|
|
|
// this.stop();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if(playPaused) { |
|
|
|
if(playPaused) { |
|
|
|
this.play(); |
|
|
|
this.play(); |
|
|
|
} |
|
|
|
} |
|
|
@ -894,8 +905,10 @@ export class AppMediaPlaybackController { |
|
|
|
listenerSetter.removeAll(); |
|
|
|
listenerSetter.removeAll(); |
|
|
|
}, {once: true}); |
|
|
|
}, {once: true}); |
|
|
|
|
|
|
|
|
|
|
|
listenerSetter.add(video)('play', () => { |
|
|
|
listenerSetter.add(video)('play', (e) => { |
|
|
|
|
|
|
|
if(this.playingMedia !== video) { |
|
|
|
this.pause(); |
|
|
|
this.pause(); |
|
|
|
|
|
|
|
} |
|
|
|
// if(this.pause()) {
|
|
|
|
// if(this.pause()) {
|
|
|
|
// listenerSetter.add(video)('pause', () => {
|
|
|
|
// listenerSetter.add(video)('pause', () => {
|
|
|
|
// this.play();
|
|
|
|
// this.play();
|
|
|
|