Skip to content

Commit 07e4dbf

Browse files
committed
➕ ADD: Player
Se agrega la pagina correspondiente al player del podcast. Issue #15
1 parent 1ae38bf commit 07e4dbf

2 files changed

Lines changed: 70 additions & 3 deletions

File tree

components/PlayerAudio.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Dependencias
22
import PropTypes from "prop-types";
3-
import React, { Fragment } from "react";
3+
import React from "react";
44

55
/**
66
* Listdado de los ultimos podcast.
@@ -11,7 +11,7 @@ const PlayerAudio = ({
1111
audioMp3, channel,
1212
poster, title,
1313
}) => (
14-
<Fragment>
14+
<>
1515
<div className="player">
1616
<picture>
1717
<img src={poster} alt={title} />
@@ -40,10 +40,26 @@ const PlayerAudio = ({
4040
margin-top: 2em;
4141
width: 100%;
4242
}
43+
picture {
44+
display: flex;
45+
align-items: center;
46+
justify-content: center;
47+
flex: 1 1;
48+
flex-direction: column;
49+
width: auto;
50+
padding: 10%;
51+
}
52+
picture img {
53+
width: 320px;
54+
height: 320px;
55+
background-position: 50% 50%;
56+
background-size: contain;
57+
background-repeat: no-repeat;
58+
}
4359
`}
4460
</style>
4561
</div>
46-
</Fragment>
62+
</>
4763
);
4864

4965
PlayerAudio.propType = {

pages/podcast.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Dependencias
2+
import PropTypes from "prop-types";
3+
import React from "react";
4+
import "isomorphic-fetch";
5+
6+
// Componentes
7+
import { PlayerAudio, Layout } from "../components";
8+
import { api, audio } from "./config.json";
9+
10+
/**
11+
* Player que permite esuchar el audio.
12+
*
13+
* @param {Object} Header Configuraciones para el header.
14+
* @param {Object} player Configuracion correspondiente el reproductor.
15+
*/
16+
const PodCast = ({ header, player }) => (
17+
<Layout header={header}>
18+
<PlayerAudio {...player} />
19+
</Layout>
20+
);
21+
22+
/**
23+
* Metodo encargado de realizar la peticion al Api.
24+
*
25+
* @param {String} query Id correspondiente al consulta.
26+
* @return {Promise}
27+
*/
28+
PodCast.getInitialProps = async ({ query }) => {
29+
const REQUEST = await fetch(`${api}${audio}/${query.id}.mp3`);
30+
const { body: { audio_clip: mp3 = { } } } = await REQUEST.json();
31+
const { channel = {}, title = "", urls = {} } = mp3;
32+
const PROPS = {
33+
audioMp3: urls.high_mp3,
34+
channel: channel.title,
35+
poster: urls.image,
36+
title,
37+
};
38+
return { header: { back: `/channel?id=${channel.id}` }, player: PROPS };
39+
};
40+
41+
PodCast.prototype = {
42+
header: PropTypes.shape(PropTypes.object),
43+
player: PropTypes.shape(PropTypes.object),
44+
};
45+
46+
PodCast.defaultProps = {
47+
header: {},
48+
player: {},
49+
};
50+
51+
export default PodCast;

0 commit comments

Comments
 (0)