Skip to content

Commit

Permalink
Added video scroll in grid expansion; Added yt eh for playerstatus;
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhitex committed Nov 27, 2016
1 parent 7c1094a commit dc70b44
Show file tree
Hide file tree
Showing 23 changed files with 535 additions and 57 deletions.
2 changes: 0 additions & 2 deletions src/RadioWatch/ClientApp/app/actions/phalanxgrid.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export class PhxGridActions {
atIndexInsert: rowInfo.index + 1,
}
});
console.log(rowInfo);
}

collapseRow(rowInfo: any) {
Expand All @@ -120,7 +119,6 @@ export class PhxGridActions {
key: rowInfo.row.key,
}
});
console.log(rowInfo);
}

private phxGridUpdatePagination() {
Expand Down
97 changes: 83 additions & 14 deletions src/RadioWatch/ClientApp/app/actions/youtube-window-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ import { IAppState } from '../store';
import { NgRedux } from 'ng2-redux';
import { List } from 'immutable';
import { ApiService } from '../services'
import { Observable } from 'rxjs';
import { Observable, Subscription, Subject } from 'rxjs';
import { YoutubeService } from '../services';
import { YOUTUBE_PLAYER_STATES, PlayerStateModel } from '../services/youtube-service'

export const YOUTUBE_WINDOW_ACTIONS = {
SEARCHING_IN_PROG: "SEARCHING_IN_PROG",
SEARCHING_SUCCESS: "SEARCHING_SUCCESS",
SEARCHING_FAILED: "SEARCHING_FAILED",
VIDEO_STARTED: "VIDEO_STARTED",
VIDEO_STOPED: "VIDEO_STOPED",
PLAYER_LOADED: "PLAYER_LOADED"
PLAYER_LOADED: "PLAYER_LOADED",
PLAYER_STATE_CHANGE: "PLAYER_STATE_CHANGE",
VIDEO_CHANGED: "VIDEO_CHANGED",
VIDEO_CHANGED_ERROR: "VIDEO_CHANGED_ERROR"
}

export const YOUTUBE_WINDOWS_ACTIONS = {
Expand Down Expand Up @@ -89,7 +93,83 @@ export class YoutubeWindowActions {
player: newPlayer,
ready: true
}
})
});
}

setupPlayerStateChangedEventListener(playerId: string, playerStateChanged$: Subject<PlayerStateModel>) {
let window = this.windowById(playerId);
this.ytService.setupPlayerStateChangedEventListener(playerId, window.player, playerStateChanged$);
return playerStateChanged$.subscribe((next) => {
this.playerStateChanged(next);
});
}

playerStateChanged(playerState: PlayerStateModel) {
let statusText: string;
for (let i in YOUTUBE_PLAYER_STATES) {
if (YOUTUBE_PLAYER_STATES[i] === playerState.statusId) {
statusText = i;
}
}
this.ngRedux.dispatch({
type: YOUTUBE_WINDOW_ACTIONS.PLAYER_STATE_CHANGE,
payload: {
playerId: playerState.playerId,
status: statusText
}
});
if (statusText === "ENDED" || statusText === "PAUSED") {
this.ngRedux.dispatch({
type: YOUTUBE_WINDOW_ACTIONS.VIDEO_STOPED,
payload: {
playerId: playerState.playerId,
playing: false
}
});
}
}

pauseVideo(playerId: string): void {
const playerWindow = this.windowById(playerId);
if (playerWindow.playing){
this.ytService.pauseVideo(playerWindow.player);
}
}

changeVideo(playerId: string, videoId: string, dataExtractor: Observable<any>) {
const playerWindow = this.windowById(playerId);
let videoData: any;
var videoFound = playerWindow.videos.find((val, key, number) => {
const sub = dataExtractor.subscribe((next) => {
videoData = next(val);
}, (err) => {
console.log(err);
}, () => { });
sub.unsubscribe();
if (videoData.videoId === videoId)
return true;
return false;
});

if (typeof videoData !== undefined && videoData) {
this.ngRedux.dispatch({
type: YOUTUBE_WINDOW_ACTIONS.VIDEO_CHANGED,
payload: {
playerId: playerId,
videoId: videoData.videoId,
videoTitle: videoData.title,
imgUrl: videoData.imgUrl,
playing: false
}
});
} else {
this.ngRedux.dispatch({
type: YOUTUBE_WINDOW_ACTIONS.VIDEO_CHANGED_ERROR,
payload: {
playerId: playerId,
}
});
}
}

startVideo(playerId: string) {
Expand All @@ -115,16 +195,6 @@ export class YoutubeWindowActions {
});
}

stopVideo(playerId: string) {
const window = this.windowById(playerId);
this.ngRedux.dispatch({
type: YOUTUBE_WINDOW_ACTIONS.VIDEO_STOPED,
payload: {
playerId: playerId,
playing: false
}
});
}

private windowById(playerId: string) {
const state = this.ngRedux.getState();
Expand All @@ -135,7 +205,6 @@ export class YoutubeWindowActions {
return playerWindow;
}
}

}

export interface IYoutubeSearch {
Expand Down
32 changes: 32 additions & 0 deletions src/RadioWatch/ClientApp/app/containers/display/test-display.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.row-centered {
text-align:center;
}
.col-centered {
display:inline-block;
float:none;
/* reset the text-align */
text-align:left;
/* inline-block space fix */
margin-right:-4px;
}

.flex-column {
display: flex;
flex-flow: column;
}

.flex-row {
display: flex;
flex-flow: row;
}

.flex-center {
display: flex;
justify-content: center;
}

.flex-container {
height: 100%;
width: 100%;
position: absolute;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>Video</h1>
<div class="flex-container">
<div class="flex-column">
<div class="flex-center">
<youtube-adapter>
</youtube-adapter>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { Component, OnInit } from '@angular/core';

@Component({
selector: 'test-display',
template: `
<h1>Video</h1>
<youtube-adapter>
</youtube-adapter>
`
template: require('./test-display.html'),
styles: [require('./test-display.css')]
})
export class TestDisplayComponent implements OnInit {
constructor() { }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.row-centered {
text-align:center;
}
.col-centered {
display:inline-block;
float:none;
/* reset the text-align */
text-align:left;
/* inline-block space fix */
margin-right:-4px;
}
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
<youtube-adapter></youtube-adapter>
<div class="container-fluid">
<div class="row row-centered">
<div class="col-centered">
<youtube-adapter [searchTerm]="searchTerm">
</youtube-adapter>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { Component, OnInit, Input } from '@angular/core';

@Component({
selector: 'phx-rmt-grid-expansion',
template: require('./phalanx-remote-grid-expansion.html')
template: require('./phalanx-remote-grid-expansion.html'),
styles: [require('./phalanx-remote-grid-expansion.css')]
})
export class PhalanxRemoteGridExpansionComponent implements OnInit {
constructor() { }

//@Input() expanded: boolean;

ngOnInit() { }
@Input() rowData: any;
searchTerm: string;
ngOnInit() {
this.searchTerm = this.rowData.data.artistName + " " + this.rowData.data.trackName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<table *ngFor="let c of displayData; let i = index;" class="table">
<tr *ngIf="c.data.isExpansionRowPhxRmtGrid">
<phx-rmt-grid-expansion></phx-rmt-grid-expansion>
<phx-rmt-grid-expansion [rowData]="displayData.get(i-1)" ></phx-rmt-grid-expansion>
</tr>
<td *ngIf="!c.data.isExpansionRowPhxRmtGrid">
<a (click)="expandOrCollapseRow(c,i)"> <i class="glyphicon glyphicon-resize-vertical"></i></a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<youtube-adapter></youtube-adapter>
<youtube-adapter-scroll>
</youtube-adapter-scroll>
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { Component, OnInit, Input } from '@angular/core';

@Component({
selector: 'phx-grid-expansion',
template: require('./phalanx-grid-expansion.html')
template: require('./phalanx-grid-expansion.html'),
})
export class PhalanxGridExpansionComponent implements OnInit {
constructor() { }

//@Input() expanded: boolean;

ngOnInit() { }
}
3 changes: 2 additions & 1 deletion src/RadioWatch/ClientApp/app/containers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export {
export {
YoutubeEmbedComponent,
YoutubeWindowComponent,
YoutubeAdapterComponent
YoutubeAdapterComponent,
YoutubeAdapterScrollComponent
} from './youtube'
export {
TestDisplayComponent
Expand Down
3 changes: 2 additions & 1 deletion src/RadioWatch/ClientApp/app/containers/youtube/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { YoutubeWindowComponent } from './youtube-window';
export { YoutubeEmbedComponent } from './youtube-embed';
export { YoutubeAdapterComponent } from './youtube-adapter';
export { YoutubeAdapterComponent } from './youtube-adapter';
export { YoutubeAdapterScrollComponent } from './youtube-adapter-scroll';
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.flex-column {
display: flex;
flex-flow: column;
}

.flex-row {
display: flex;
flex-flow: row;
}

.flex-center {
display: flex;
justify-content: center;
}

.flex-container {
height: 100%;
width: 100%;
position: absolute;
}

.image-wrap {
position: relative;
display: inline-block;
}

.empty-block {
position: relative;
display: inline-block;
height: 200px;
width: 356px;
}


.clear-gif {
background-image: url("../../img/clear.gif");
background-size: 200px 356px;
}


.perspective-right {
-webkit-perspective: 400px;
-moz-perspective: 400px;
width:356px;
height:200px;
float:left;
}
.transform-right{

width:100%;
height:100%;
/*overflow:scroll;*/
-webkit-transform: rotateX(0deg) rotateY(-20deg) translateZ(-20px) translateX(-10px);
-moz-transform: rotateX(0deg) rotateY(-20deg) translateZ(-20px) translateX(-10px);
}

.perspective-left {
-webkit-perspective: 400px;
-moz-perspective: 400px;
width:356px;
height:200px;
float:left;
}
.transform-left{

width:100%;
height:100%;
/*overflow:scroll;*/
-webkit-transform: rotateX(0deg) rotateY(20deg) translateZ(-20px) translateX(10px);
-moz-transform: rotateX(0deg) rotateY(20deg) translateZ(-20px) translateX(10px);
}
Loading

0 comments on commit dc70b44

Please sign in to comment.