Last active
April 19, 2016 10:28
-
-
Save enriqueaf/2eede6da3a4fa093a6e99744dc9b1f71 to your computer and use it in GitHub Desktop.
Song player
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
actions: { | |
stopMusic() { | |
this.sendAction('stopMusic'); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
/** | |
* Title of the song that can play. | |
* | |
* @property title | |
*/ | |
title: null, | |
/** | |
* State of the music | |
* | |
* @property isPlaying | |
* @type boolean | |
* @default false | |
*/ | |
isPlaying: false, | |
/** | |
* Source of the music to be played | |
* | |
* @property src | |
* @type string | |
*/ | |
src: null, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { isNone } = Ember; | |
export default Ember.Controller.extend({ | |
musicIsPlaying: false, | |
currentSong: null, | |
actions: { | |
playSong(currentSong) { | |
this.set('musicIsPlaying', true); | |
this.set('currentSong', currentSong); | |
}, | |
stopMusic() { | |
this.set('musicIsPlaying', false); | |
this.set('currentSong', null); | |
}, | |
playMusic() { | |
if(!isNone(this.get('currentSong'))) { | |
this.set('musicIsPlaying', true); | |
} | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { isNone } = Ember; | |
export function isPlaying(params/*, hash*/) { | |
if(isNone(params[1])) { | |
return false; | |
} else { | |
return params[0].src === params[1].src; | |
} | |
} | |
export default Ember.Helper.helper(isPlaying); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Object.extend({ | |
src: 'defualt.mp4', | |
title: 'Random title' | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none' | |
}); | |
Router.map(function() { | |
this.route('songs', { path: '/'} ); | |
}); | |
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import Song from '../models/song'; | |
const songs = [ | |
['srcaaa.mp4', 'otro titulo'], | |
['dddaaa.mp4', 'el mejor titulo'], | |
]; | |
export default Ember.Route.extend({ | |
model() { | |
return songs.map((song) => { | |
return Song.create({ | |
src: song[0], | |
title: song[1] | |
}); | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.clickable { | |
cursor: pointer; | |
color: red; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.7.2", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.4.4", | |
"ember-data": "2.4.3", | |
"ember-template-compiler": "2.4.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment