Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: shsa-odoo/Single_Page_Application_workshop
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0640e4dd2dd1030dbb5407d8b4c35b6aedf2d40e
Choose a base ref
..
head repository: shsa-odoo/Single_Page_Application_workshop
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 20cec9eb8846b5f08d6ebe97937dc388c847871c
Choose a head ref
Showing with 23 additions and 15 deletions.
  1. BIN music_player/controllers/__pycache__/controllers.cpython-38.pyc
  2. +15 −15 music_player/controllers/controllers.py
  3. +8 −0 music_player/static/app.js
Binary file modified music_player/controllers/__pycache__/controllers.cpython-38.pyc
Binary file not shown.
30 changes: 15 additions & 15 deletions music_player/controllers/controllers.py
Original file line number Diff line number Diff line change
@@ -4,20 +4,20 @@
import json

class MusicPlayer(http.Controller):
@http.route('/music', auth='public')
def index(self, **kw):
return http.request.render('music_player.music_template')
@http.route('/music', auth='public')
def index(self, **kw):
return http.request.render('music_player.music_template')

@http.route('/music/search', auth='public',type="http",methods=['GET'])
def search(self, **kw):
song_name = kw.get('song_name')
songs = http.request.env['music_player.music_player'].search_read([('name','ilike',song_name)],fields=["name","url"])
if not songs:
songs = "Song not found."
return http.Response(json.dumps({'result':songs}),content_type='application/json')
@http.route('/music/search', auth='public',type="http",methods=['GET'])
def search(self, **kw):
song_name = kw.get('song_name')
songs = http.request.env['music_player.music_player'].search_read([('name','ilike',song_name)],fields=["name","url"])
if not songs:
songs = "Song not found."
return http.Response(json.dumps({'result':songs}),content_type='application/json')

@http.route('/music/<model("music_player.music_player"):music>',type="http",auth="public",methods=['GET'])
def load(self,music,**kw):
music_file_path = get_module_resource('music_player','static/songs',music.filename)
file = open(music_file_path,'rb').read()
return file
@http.route('/music/<model("music_player.music_player"):music>',type="http",auth="public",methods=['GET'])
def load(self,music,**kw):
music_file_path = get_module_resource('music_player','static/songs',music.filename)
file = open(music_file_path,'rb').read()
return file
8 changes: 8 additions & 0 deletions music_player/static/app.js
Original file line number Diff line number Diff line change
@@ -56,6 +56,10 @@ class PlayList extends Component {
}

playSong(ev) {
if (audio) {
audio.pause();
audio.currentTime=0;
}
const selectedSongUrl = ev.target.getAttribute('value');
const selectedSong = this.props.playData.find(song => song.url===selectedSongUrl);
document.getElementById("song-title").textContent = selectedSong.name;
@@ -80,6 +84,10 @@ class List extends Component {
`;

playSong(ev) {
if (audio) {
audio.pause();
audio.currentTime=0;
}
const selectedSongUrl = ev.target.getAttribute('value');
const selectedSong = this.props.searchData[0].find(song => song.url===selectedSongUrl);
document.getElementById("song-title").textContent = selectedSong.name;