Skip to content

Commit

Permalink
Merge pull request #159 from mgireesha/158-lyrics-make-scroll-smooth
Browse files Browse the repository at this point in the history
158 lyrics make scroll smooth
  • Loading branch information
mgireesha authored Oct 20, 2024
2 parents fda5221 + f0d0b3a commit d809e9a
Show file tree
Hide file tree
Showing 52 changed files with 508 additions and 873 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.gmt</groupId>
<artifactId>g-player</artifactId>
<version>2.4.10</version>
<version>2.4.20</version>
<name>G-Player-SB</name>
<description>G-Player-SB</description>
<properties>
Expand Down
3 changes: 1 addition & 2 deletions src/g-player-react/src/Components/history/RecentPlays.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Header } from "../header/Header";
import { CURRENT_PAGE, RECENT_PLAYS, RECENT_PLAYS_LABEL } from "../redux/GPActionTypes";
import { fetchAllHistory } from "../redux/library/LibraryActions";
import { AlbumThumbsGrouped } from "../screen/album/AlbumThumbsGrouped";
import { Track } from "../screen/track/Track";
import { AlbumThumb } from "../screen/album/AlbumThumb";
import { setCookies } from "../utilities/util";
import { TrackList } from "../screen/track/TrackList";
Expand All @@ -20,7 +19,7 @@ export const RecentPlays = () => {
useEffect(()=>{
dispatch(fetchAllHistory());
setCookies(CURRENT_PAGE, JSON.stringify({type:RECENT_PLAYS}));
},[])
},[dispatch])

useEffect(()=>{
if(historyAlbums!==undefined){
Expand Down
2 changes: 1 addition & 1 deletion src/g-player-react/src/Components/library/BuildLibrary.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react";
import { ARTIST_IMG_DOWNLOAD_STATUS, BUILD_STATUS, COMPLETED, COMPONENT, CURRENT_PAGE, GP_LIBRARY_DESCRIPTION, GP_LIBRARY_DESC_TEXT_1, INIT, INITIATED, LIBRARY, LIBRARY_BUILD, LIBRARY_LABEL, MUSIC_PATH, RUNNING } from "../redux/GPActionTypes";
import { BUILD_STATUS, COMPONENT, GP_LIBRARY_DESCRIPTION, GP_LIBRARY_DESC_TEXT_1, INIT, INITIATED, LIBRARY_BUILD, RUNNING } from "../redux/GPActionTypes";
import { fetchBuildStatusSucc, initLibraryBuild, setCommonPopupObj } from "../redux/library/LibraryActions";
import { useDispatch, useSelector } from "react-redux";
import { setCookies } from "../utilities/util";
Expand Down
50 changes: 45 additions & 5 deletions src/g-player-react/src/Components/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1800,10 +1800,23 @@ a.disabled-click{
position: relative;
overflow: hidden;

.lyrics-lines::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}

.lyrics-lines{
overflow-y: auto;
max-height: 6.2em;

display: flex;
flex-direction: column;
row-gap: 10px;
}

.show-lyrics-btn-container{
position: absolute;
bottom: 0;
left: 3.5%;
left: 6%;
width: 90%;
height: 20%;

Expand All @@ -1825,8 +1838,11 @@ a.disabled-click{
text-overflow: ellipsis;
/*to show dots if text is too long - end*/

span{
>span{
font-size: 14px;
display:flex;
align-items: center;
justify-content: flex-end;
}
}

Expand Down Expand Up @@ -1859,6 +1875,11 @@ a.disabled-click{
// padding: 7.3px 15.3px;
// }

.edit-lyrics{
width: 100%;
height: 92%;
}

#new_lyrics_ta{
margin-bottom: 7%;
margin-top: 3%;
Expand Down Expand Up @@ -1900,11 +1921,26 @@ a.disabled-click{
}

.create-lyrics{
height: 100%;
width: 100%;
max-height:85%;
overflow-y:auto;
margin-left:20%;
.show-lyrics-btn-container{
display: flex;
//align-items: center;
padding: 0 15px;
column-gap: 10px;
.create-lyrics-btn-container{
display: flex;
flex-direction: column;
row-gap: 5px;
justify-content: center;
width: 3em;
>div{
display: flex;
flex-direction: column;
row-gap: 5px;
position: absolute;
}
button{
cursor: pointer;
svg{
Expand Down Expand Up @@ -1936,6 +1972,10 @@ a.disabled-click{
height: 100%;
overflow-y: hidden;

.lyrics-lines{
max-height: 22em;
}

.show-lyrics-btn-container{
height: 10%;
}
Expand Down Expand Up @@ -3485,7 +3525,7 @@ a.disabled-click{
.header-container{
.header{
display: flex;
align-items: end;
align-items: flex-end;
column-gap: 10px;
div{
svg{
Expand Down
60 changes: 46 additions & 14 deletions src/g-player-react/src/Components/player/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@ import { FaPauseCircle, FaPlay } from "react-icons/fa";
import { MdOutlineLyrics, MdSkipNext, MdSkipPrevious } from "react-icons/md";
import { TiArrowRepeat } from "react-icons/ti";
import { TbArrowsShuffle , TbRepeatOnce} from "react-icons/tb";
import { RiRefreshLine } from "react-icons/ri";
import { useDispatch, useSelector } from "react-redux";
import { fettchCurrentSongStatus, playASong, playPause, setIsPlaying, setIsShuffle, setPlayBackLength, setRepeat } from "../redux/player/PlayerActions";
import { getMins, scrolltoId, scrollToPlaying, setCookies } from "../utilities/util";
import { VolumeH } from "./VolumeH";
import { Link } from "react-router-dom";
import { fetchAllHistory, updateHistory } from "../redux/library/LibraryActions";
import { SliderRC } from "../SliderRC";
import { CURRENT, NEXT, PLAYER, PLAYLIST, PREVIOUS, REPEAT_ALL, REPEAT_OFF, REPEAT_ONE } from "../redux/GPActionTypes";

import { ALBUM, ARTIST, CURRENT, GENRE, LANGUAGE, NEXT, PLAYER, PLAYLIST, PREVIOUS,
RECENT_PLAYS, REPEAT_ALL, REPEAT_OFF, REPEAT_ONE, TRACKS } from "../redux/GPActionTypes";
import def_album_art from '../images/def_album_art.png';
import { SplitAndLink } from "../utilities/SplitAndLink";
import { RefreshBuild } from "./RefreshBuild";
import { useCookies } from "react-cookie";

export const Player = () => {

const dispatch = useDispatch();

const [cookies] = useCookies();

const playerTracks = useSelector(state => state.library.playerTracks);
const isPlaying = useSelector(state => state.player.isPlaying);
const repeat = useSelector(state => state.player.repeat);
const isShuffle = useSelector(state => state.player.isShuffle);
const songPlaying = useSelector(state => state.player.songPlaying);
let songPlaying = useSelector(state => state.player.songPlaying);
const playedFrom = useSelector(state => state.player.playedFrom);
const playingSongStat = useSelector(state => state.player.playingSongStat);
const playlistSongs = useSelector(state => state.playlist.playlistSongs);
Expand All @@ -44,7 +46,6 @@ export const Player = () => {
var key = event.which || event.keyCode; // keyCode detection
var ctrl = event.ctrlKey ? event.ctrlKey : ((key === 17) ? true : false); // ctrl detection
var shift = event.shiftKey ? event.shiftKey : ((key === 16) ? true : false);
//console.log("key",key,"ctrl",ctrl,"shift",shift)
if(ctrl){
switch (key) {
case 32:
Expand All @@ -63,9 +64,9 @@ export const Player = () => {

if (shift) {
if(playingSongStat && playingSongStat.currentTime){
if(key == 39){
if(key === 39){
setSlctdPlayBackTime(currentPlayVal+5);
}else if(key == 37){
}else if(key === 37){
setSlctdPlayBackTime(currentPlayVal-5);
}
}
Expand All @@ -75,6 +76,7 @@ export const Player = () => {
return () => {
window.removeEventListener('keyup', handleEscape);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [songPlaying,playingSongStat]);

useEffect(()=>{
Expand All @@ -84,6 +86,7 @@ export const Player = () => {
useEffect(()=>{
clearInterval(statClearIntrvl);
if(isPlaying)setStatClearIntrvl(setInterval( dispatchFetchStat, 500));
// eslint-disable-next-line react-hooks/exhaustive-deps
},[songPlaying,isPlaying]);

useEffect(()=>{
Expand All @@ -96,23 +99,23 @@ export const Player = () => {
rBtn.classList.remove('rotate-player-button');
}));

[...document.getElementsByClassName('player-controls')].forEach(pc => {pc.classList.remove('opacity-player-console')})
[...document.getElementsByClassName('player-controls')].forEach(pc => {pc.classList.remove('opacity-player-console')});
// eslint-disable-next-line react-hooks/exhaustive-deps
},[songPlaying]);

useEffect(()=>{
const tempPlayTime = playTime;
if(playTime===10000 && songPlaying!==null){
dispatch(updateHistory(songPlaying.songId));
}

if(playTime===12000){
dispatch(fetchAllHistory());
}

if(playTime > 4000 && Number.isInteger(playTime/5000)){
setCookies("playingSongStat",JSON.stringify(playingSongStat));
}
setPlayTime(tempPlayTime+500);
// eslint-disable-next-line react-hooks/exhaustive-deps
},[playingSongStat])

useEffect(()=>{
Expand All @@ -133,6 +136,7 @@ export const Player = () => {
const pBarval = Math.floor((currentTime/trackLength)*100);
setCurrentplayVal(pBarval);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
},[playingSongStat]);

const dispatchFetchStat = () => {
Expand All @@ -141,6 +145,7 @@ export const Player = () => {

useEffect(()=> {
getSetLibrary();
// eslint-disable-next-line react-hooks/exhaustive-deps
},[isShuffle, playerTracks]);

const getSetLibrary = () => {
Expand Down Expand Up @@ -261,20 +266,47 @@ export const Player = () => {
setCookies("isShuffle", true);
}
}

const getToPageURL = (songPlaying) => {
let url = '#';
const playedFrom = cookies['playedFrom'];
if(playedFrom){
if(playedFrom.pfKey===PLAYLIST){
url = `/playlist/${playedFrom.pfField?.name}/${playedFrom.pfVal}`;
}else if(playedFrom.pfKey===ARTIST){
url = `music/artists/${playedFrom.pfVal}`;
}else if(playedFrom.pfKey===ALBUM){
url = `/music/albums/${songPlaying?.album}`;
}else if(playedFrom.pfKey===GENRE){
url = `/music/genres/${playedFrom.pfVal}`;
}else if(playedFrom.pfKey===LANGUAGE){
url = `/music/languages/${playedFrom.pfVal}`;
}else if(playedFrom.pfKey===RECENT_PLAYS){
url = `/recent`;
}else if(playedFrom.pfKey===TRACKS){
url = `/music/tracks`;
}
}else if(songPlaying){
url = `/music/albums/${songPlaying.album}`;
}
return url;
}

return (
<div className="player">
<div className="player-container">
<div className="song-info">
<Link to={songPlaying!==null?`/music/albums/${songPlaying.album}`:'#'}>
<div className="song-info-img">
<img src={songPlaying ?`/gp_images/albums/${songPlaying.album}.jpg`: def_album_art} />
{/* {songPlayingImg !== null && songPlayingImg!=='' && <img src={songPlayingImg} />}
{(songPlayingImg===null || songPlayingImg==='') && <img src={def_album_art} />} */}
<img src={songPlaying ?`/gp_images/albums/${songPlaying.album}.jpg`: def_album_art} alt={songPlaying?.album} />
</div>
</Link>
<div className="song-info-title">
<p onClick={()=>scrollToPlaying(isPlaying)} style={{cursor:'pointer'}}>{songPlaying && songPlaying.title}{songPlaying && songPlaying.lyricsAvl && <span><MdOutlineLyrics title="This track has lyrics" style={{margin:'5px 0 0 5px'}} /></span>}</p>
<Link to={getToPageURL(songPlaying)}>
<p onClick={()=>scrollToPlaying(isPlaying)} style={{cursor:'pointer'}}>
{songPlaying && songPlaying.title}{songPlaying && songPlaying.lyricsAvl && <span><MdOutlineLyrics title="This track has lyrics" style={{margin:'5px 0 0 5px'}} /></span>}
</p>
</Link>
<p style={{maxHeight: '3em',overflow: 'auto'}}>{songPlaying!==null && <SplitAndLink str={songPlaying.artist} url={`/music/artists/`} />}</p>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";
import { COMING_SOON_LABEL, CSV_IMPORT_INPUT, EXPORT_LABEL, GP_IMPORT_INPUT, IMPORT_LABEL, IMPORT_PLAYLISTS_LABEL } from "../redux/GPActionTypes";
import { COMING_SOON_LABEL, CSV_IMPORT_INPUT, EXPORT_LABEL, GP_IMPORT_INPUT, IMPORT_LABEL } from "../redux/GPActionTypes";
import { useDispatch, useSelector } from "react-redux";
import { exportPlaylists, importPlaylists } from "../redux/playlist/PlaylistActions";
import { setCommonPopupObj } from "../redux/library/LibraryActions";
Expand All @@ -12,7 +12,6 @@ export const ImportExportPlaylistPopupBtns = () => {

const [showImportOptions, setShowImportOptions] = useState(false);
const [showSpinner, setShowSpinner] = useState(false);
const [selectedFiles, setSelectedFiles] = useState({});

const onExportPlaylists = () => {
if(window.confirm("Export Playlists ?")===true){
Expand Down Expand Up @@ -51,31 +50,23 @@ export const ImportExportPlaylistPopupBtns = () => {
playlistName = playlistName.substring(0, playlistName.length-fileType.length);
fileReader = new FileReader();
fileReader.readAsText(file);
// eslint-disable-next-line
const result = await new Promise((resolve, reject) => {
fileReader.onload = function(event) {
resolve(fileReader.result)
}
})
tempSelectedFiles[playlistName] = result.split("\r\n");
}
if(fileType === '.csv'){
setSelectedFiles(tempSelectedFiles);
}else if(fileType === '.gp'){
if(fileType === '.gp'){
tempSelectedFiles = getGPPLPayload(tempSelectedFiles);
}

/*console.log("tempSelectedFiles",tempSelectedFiles);
const tempCommonPopupObj = {...commonPopupObj};
tempCommonPopupObj.payload = tempSelectedFiles;
tempCommonPopupObj.dispatchPayload = true;
dispatch(setCommonPopupObj(tempCommonPopupObj));*/
return tempSelectedFiles;
}

const getGPPLPayload = (selectedFiles) => {
const tempSelectedFiles = {};
const plNames = Object.keys(selectedFiles);
//let plItem;
let plItems;
let track = {};
let tracks = [];
Expand Down Expand Up @@ -117,7 +108,6 @@ export const ImportExportPlaylistPopupBtns = () => {
dispatch(importPlaylists(selectedFiles, fileType));
}
}

}

return(
Expand All @@ -138,10 +128,10 @@ export const ImportExportPlaylistPopupBtns = () => {
}
{showImportOptions &&
<>
{!showSpinner &&
{!showSpinner ?
<div className="import-options">
<div className="import-csv">
<input type="file" className="csv" accept=".csv" multiple id={CSV_IMPORT_INPUT} /*onChange={(event)=>handleFileOnChange(event)}*/ />
<input type="file" className="csv" accept=".csv" multiple id={CSV_IMPORT_INPUT} />
</div>
<div className="import-gp">
<input type="file" className="gp" accept=".gp" multiple id={GP_IMPORT_INPUT} />
Expand All @@ -150,8 +140,8 @@ export const ImportExportPlaylistPopupBtns = () => {
<input type="file" className="m3u" accept=".m3u" multiple disabled title={COMING_SOON_LABEL} />
</div>
</div>
: <div className="flex-align-center-100"><Spinner spinnerInp={{classSize:'sm', text:"Importing"}} /></div>
}
{showSpinner && <div className="flex-align-center-100"><Spinner spinnerInp={{classSize:'sm', text:"Importing"}} /></div>}
</>
}
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/g-player-react/src/Components/redux/GPActionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ export const SEARCH_RESULTS_LABEL = 'Search Results';
export const SELECT_TRACKS_LABEL = 'Select tracks';
export const UNSELECT_TRACKS_LABEL = 'Unselect tracks';
export const SHOW_ASSIGNED_PLAYLISTS = 'SHOW_ASSIGNED_PLAYLISTS';
export const SHOW_CREATE_LYRICS = 'SHOW_CREATE_LYRICS';
export const SHOW_EDIT_LYRICS = 'SHOW_EDIT_LYRICS';
export const SHOW_LYRICS = 'SHOW_LYRICS';
export const SOME_PAGE = 'SOME_PAGE';
export const SORT_A_TO_Z = 'SORT_A_TO_Z';
export const SORT_A_TO_Z_DESC = 'SORT_A_TO_Z_DESC';
Expand Down
2 changes: 1 addition & 1 deletion src/g-player-react/src/Components/screen/album/Album.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useDispatch, useSelector } from "react-redux";
import { Link, useNavigate, useParams } from "react-router-dom";
import def_album_art from '../../images/def_album_art.png';
import { ALBUM, CURRENT_PAGE, EDIT_INFO_LABEL, MULTI_LINGUAL, SORT_A_TO_Z, SORT_A_TO_Z_DESC, SORT_TRACK_NUMBER, TRACKS_LABEL } from ".././../redux/GPActionTypes";
import { Lyrics } from "../lyrics/Lyrics";
import { Lyrics } from "../lyrics/LyricsV2";
import { fetchAlbum, fetchAlbumTacks, setMetadataPopupObj } from "../../redux/library/LibraryActions";
import { camelize, setCookies } from "../../utilities/util";
import { TrackList } from "../track/TrackList";
Expand Down
Loading

0 comments on commit d809e9a

Please sign in to comment.