diff --git a/ci/application/controllers/Albums.php b/ci/application/controllers/Albums.php index 6864367..4b5549b 100644 --- a/ci/application/controllers/Albums.php +++ b/ci/application/controllers/Albums.php @@ -40,9 +40,10 @@ class Albums extends CI_Controller { } $playlists = $this->model_music->getPlaylist(); $this->load->view('layout/header'); - $this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]); + $this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]); $this->load->view('layout/footer'); - } + +} public function addAllSongsToPlaylist(){ $album_id = $this->input->post('album_id'); diff --git a/ci/application/controllers/Song.php b/ci/application/controllers/Song.php index 4056ef7..ff1e5e9 100644 --- a/ci/application/controllers/Song.php +++ b/ci/application/controllers/Song.php @@ -10,9 +10,10 @@ class Song extends CI_Controller { public function view($album_id){ $songs = $this->model_music->getSongOfAlbum($album_id); + $duration = $this->model_music->getDurationSong($songs); $playlists = $this->model_music->getPlaylist(); $this->load->view('layout/header'); - $this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]); + $this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists, 'duration' => $duration]); $this->load->view('layout/footer'); } } diff --git a/ci/application/models/Model_music.php b/ci/application/models/Model_music.php index cf1a795..ca3cbe5 100644 --- a/ci/application/models/Model_music.php +++ b/ci/application/models/Model_music.php @@ -92,9 +92,11 @@ class Model_music extends CI_Model { public function getSongOfAlbum($album_id){ $query = $this->db->query( - "SELECT song.id, song.name + "SELECT song.id, song.name, track.duration FROM song INNER JOIN track ON song.id = track.songId + + WHERE track.albumId = ?", array($album_id) ); @@ -237,4 +239,5 @@ class Model_music extends CI_Model { WHERE id = ?", array($new_playlist_id, $playlist_id)); } + } diff --git a/ci/application/views/song_album_list.php b/ci/application/views/song_album_list.php index 00b74c9..af0df78 100644 --- a/ci/application/views/song_album_list.php +++ b/ci/application/views/song_album_list.php @@ -1,10 +1,15 @@
jpeg) . '" alt="' . $album->name . '" />'; +echo ""; foreach($songs as $song){ echo "
"; echo "
"; - echo "{$song->name} "; - + $i = $i+1; + $minutes = floor($song->duration/60); + $secondes = $song->duration %60; + echo "{$i} - {$song->name} : {$minutes} min {$secondes} sec"; if ($this->session->userdata('logged')): echo "
"; echo "