Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radioking integration #3

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3838ca2
stream + artworks working
hugomassing Dec 23, 2017
9d9fd93
refactor css
hugomassing Dec 24, 2017
019b339
history + css working
hugomassing Dec 26, 2017
58e7f04
increase history
hugomassing Dec 26, 2017
ed55881
add responsive on controls
hugomassing Dec 26, 2017
823c2fe
remove album
hugomassing Dec 26, 2017
452ccc1
change info size
hugomassing Dec 26, 2017
1f773db
change logo position
hugomassing Dec 26, 2017
714a0b3
add hover on tracks
hugomassing Dec 26, 2017
002ab63
loading on end track kinda working
hugomassing Dec 27, 2017
bfd6f12
change animation css
hugomassing Dec 29, 2017
2ffe05a
updated stream link
hugomassing Mar 18, 2018
585ff69
refactor fetching track
hugomassing Mar 18, 2018
2be939f
added https for the stream
hugomassing Mar 18, 2018
047c398
Add missing quick-hash in deps
Kerumen Apr 8, 2018
ecf7496
Fix track shrink
Kerumen Apr 8, 2018
0138d62
Clean code
Kerumen Apr 8, 2018
89d4103
Upgrade deps
Kerumen Apr 8, 2018
eed62be
Add prettier
Kerumen Apr 8, 2018
847f0fe
Add lint-staged to run prettier on commits
Kerumen Apr 8, 2018
4c0d78c
Some more code cleaning
Kerumen Apr 8, 2018
cd95170
fix(Audio): player now stop and take back to direct
hugomassing Apr 8, 2018
3078c71
fix css and stream issues
hugomassing Jul 1, 2018
fa6bc6f
add control colume and mute
hugomassing Jul 2, 2018
96afff6
remove unused variables
hugomassing Jul 2, 2018
80091e0
fix autoplay
hugomassing Jul 3, 2018
b099832
fix responsive
hugomassing Jul 3, 2018
feaadd0
fix player volume
hugomassing Jul 4, 2018
6ee9cea
fix view on mobile
hugomassing Jul 9, 2018
9404e5f
fix title
hugomassing Sep 25, 2018
4378800
Update index.js
hugomassing Sep 27, 2018
ab41d2c
refresh
hugomassing May 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/Audio/Audio.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react'
import Sound from 'react-sound'
import { connect } from 'react-redux'
import { soundManager } from 'soundmanager2'
import Velocity from 'velocity-animate'
import { extend } from 'lodash'
import { togglePlaying, updateVolume } from '../../actions/playerActions'
Expand All @@ -9,6 +10,8 @@ import '../../styles/Controls.css'

const STREAM_URL = 'https://listen.radioking.com/radio/117904/stream/157294'

soundManager.setup({ debugMode: false })

class Audio extends Component {
audio = null

Expand All @@ -22,8 +25,6 @@ class Audio extends Component {
}
}

componentDidMount() {}

handlePlayPause = event => {
const { player, togglePlaying } = this.props
const { playingStatus } = this.state
Expand Down
43 changes: 6 additions & 37 deletions src/components/TracksList/TracksList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { Component } from 'react'
import { connect } from 'react-redux'
import moment from 'moment'
import classnames from 'classnames'
import Info from './../Info'
import { fetchCurrentTrack } from '../../actions/tracksActions'
Expand All @@ -9,65 +8,35 @@ import noCover from '../../images/notrack.jpg'

import '../../styles/TrackList.css'

const INTERVAL = 10000

class TracksList extends Component {
interval1 = null
interval2 = null

state = {
trackFocused: null,
currentTrack: 0,
tracks: [],
nextTrackReady: false,
}

componentDidMount() {
this.interval1 = setInterval(this.isCurrentTrackFinished, 5000)
this.interval2 = setInterval(this.isNextTrackReady, 5000)
this.interval1 = setInterval(this.fetchNextTrack, INTERVAL)
}

componentWillReceiveProps(nextProps) {
const { tracks, isNextTrackReady } = nextProps
const { tracks } = nextProps
const { currentTrack } = this.state
this.setState({
tracks: tracks.list.slice(currentTrack),
})
if (isNextTrackReady) {
this.setState({
nextTrackReady: true,
})
}
}

componentWillUnmount() {
clearInterval(this.interval1)
clearInterval(this.interval2)
}

isCurrentTrackFinished = () => {
const { tracks, currentTrack, nextTrackReady } = this.state
if (tracks[currentTrack].end_at) {
const isTrackFinished = moment().isAfter(
moment(tracks[currentTrack].end_at).add(30, 'seconds')
)
if (isTrackFinished && nextTrackReady) {
this.setState({
nextTrackReady: false,
})
}
}
}

isNextTrackReady = () => {
const { tracks, currentTrack, nextTrackReady } = this.state

if (tracks[currentTrack].end_at) {
const isTrackAlmostFinished = moment().isAfter(
moment(tracks[currentTrack].end_at).add(20, 'seconds')
)
if (isTrackAlmostFinished && !nextTrackReady) {
this.props.fetchCurrentTrack()
}
}
fetchNextTrack = () => {
this.props.fetchCurrentTrack()
}

onMouseOver = track => {
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import 'react-sound'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this working? 🤔


import App from './components/App'
import store from './store'
Expand Down