Permalink
Browse files

Adding audio app to sample_controls

  • Loading branch information...
1 parent 2833a47 commit a105afe2bc8db442dd841d839997f80a6c848792 Juan Pinzon committed with Charles Jolley Mar 22, 2010
View
@@ -101,6 +101,10 @@ config :sproutweets,
config :video,
:required => ['sproutcore', 'sproutcore/media']
+config :audio,
+ :required => ['sproutcore', 'sproutcore/media']
+
+
# Setup extra services to proxy. This is used only in dev mode so you can
# talk to backend services.
@@ -0,0 +1,24 @@
+// ==========================================================================
+// Project: Audio.audioController
+// Copyright: ©2009 Apple Inc.
+// ==========================================================================
+/*globals Audio */
+
+/** @class
+
+ (Document Your Controller Here)
+
+ @extends SC.Object
+*/
+Audio.audioController = SC.ArrayController.create(
+/** @scope Audio.audioController.prototype */ {
+
+ audioURL: 'http://www.joshwoodward.com/mp3/JoshWoodward-IllBeRightBehindYouJosephine.mp3',
+
+ audioURLObserver: function(){
+ debugger;
+ var url = this.get('selection').firstObject().get('url');
+ if(url) this.set('audioURL', url);
+ }.observes('selection')
+
+}) ;
View
@@ -0,0 +1,27 @@
+// ==========================================================================
+// Project: Audio
+// Copyright: ©2010 My Company, Inc.
+// ==========================================================================
+/*globals Audio */
+
+/** @namespace
+
+ My cool new app. Describe your application.
+
+ @extends SC.Object
+*/
+Audio = SC.Application.create(
+ /** @scope Audio.prototype */ {
+
+ NAMESPACE: 'Audio',
+ VERSION: '0.1.0',
+
+ // This is your application store. You will use this store to access all
+ // of your model data. You can also set a data source on this store to
+ // connect to a backend server. The default setup below connects the store
+ // to any fixtures you define.
+ store: SC.Store.create().from(SC.Record.fixtures)
+
+ // TODO: Add global constants or singleton objects needed by your app here.
+
+}) ;
@@ -0,0 +1,23 @@
+// ==========================================================================
+// Project: Audio.Audio Fixtures
+// Copyright: ©2010 My Company, Inc.
+// ==========================================================================
+/*globals Audio */
+
+sc_require('models/audio');
+
+Audio.Audio.FIXTURES = [
+
+ { "guid": "1",
+ "name": "Song1",
+ "url": 'http://www.joshwoodward.com/mp3/JoshWoodward-IllBeRightBehindYouJosephine.mp3' },
+
+ { "guid": "2",
+ "name": "Song2",
+ "url": 'http://www.joshwoodward.com/mp3/JoshWoodward-IllBeRightBehindYouJosephine.mp3' },
+
+ { "guid": "3",
+ "name": "Song3",
+ "url": 'http://www.joshwoodward.com/mp3/JoshWoodward-IllBeRightBehindYouJosephine.mp3' }
+
+];
View
@@ -0,0 +1,33 @@
+// ==========================================================================
+// Project: Audio
+// Copyright: ©2010 My Company, Inc.
+// ==========================================================================
+/*globals Audio */
+
+// This is the function that will start your app running. The default
+// implementation will load any fixtures you have created then instantiate
+// your controllers and awake the elements on your page.
+//
+// As you develop your application you will probably want to override this.
+// See comments for some pointers on what to do next.
+//
+Audio.main = function main() {
+
+ // Step 1: Instantiate Your Views
+ // The default code here will make the mainPane for your application visible
+ // on screen. If you app gets any level of complexity, you will probably
+ // create multiple pages and panes.
+ Audio.getPath('mainPage.mainPane').append() ;
+
+ // Step 2. Set the content property on your primary controller.
+ // This will make your app come alive!
+
+ // TODO: Set the content property on your primary controller
+ // ex: Audio.contactsController.set('content',Audio.contacts);
+ var files = Audio.store.find(Audio.Audio);
+ Audio.audioController.set('content', files);
+
+
+} ;
+
+function main() { Audio.main(); }
@@ -0,0 +1,18 @@
+// ==========================================================================
+// Project: Audio.Audio
+// Copyright: ©2010 My Company, Inc.
+// ==========================================================================
+/*globals Audio */
+
+/** @class
+
+ (Document your Model here)
+
+ @extends SC.Record
+ @version 0.1
+*/
+Audio.Audio = SC.Record.extend(
+/** @scope Audio.Audio.prototype */ {
+ name: SC.Record.attr(String),
+ url: SC.Record.attr(String)
+}) ;
@@ -0,0 +1,9 @@
+<% content_for :loading do %>
+<% # Any HTML in this file will be visible on screen while your page loads
+ # its application JavaScript. SproutCore applications are optimized for
+ # caching and startup very fast, so your users will often only see this
+ # content for a brief moment on their first app load, if at all.
+%>
+<p class="loading">Loading...<p>
+
+<% end %>
@@ -0,0 +1,78 @@
+// ==========================================================================
+// Project: Audio - mainPage
+// Copyright: ©2010 My Company, Inc.
+// ==========================================================================
+/*globals Audio */
+Audio.audioURL= 'http://www.joshwoodward.com/mp3/JoshWoodward-IllBeRightBehindYouJosephine.mp3';
+
+// This page describes the main user interface for your application.
+Audio.mainPage = SC.Page.design({
+
+ // The main pane is made visible on screen as soon as your app is loaded.
+ // Add childViews to this pane for views to display immediately on page
+ // load.
+ mainPane: SC.MainPane.design({
+ childViews: 'container'.w(),
+
+ container: SC.View.design({
+ layout: { centerX: 0, centerY: 0, width: 1024, height: 480 },
+ childViews: 'list html5container qtcontainer flashcontainer'.w(),
+
+ list: SC.ScrollView.design({
+ layout: { top: 0, left: 0, width: 256, bottom: 0 },
+ contentView: SC.ListView.design({
+ contentBinding: "Audio.audioController.arrangedObjects",
+ selectionBinding: "Audio.audioController.selection",
+ // setup visual display
+ contentValueKey: "name",
+ rowHeight: 32
+ })
+ }),
+ html5container: SC.View.design({
+ layout: { top: 100, left: 256, width: 256, bottom: 100 },
+ childViews: 'audioPlayer audioProperties'.w(),
+ audioPlayer:SC.AudioView.design({
+ degradeList: ['html5'],
+ layout: { top: 0, centerX:0, width: 200, height: 20},
+ valueBinding: 'Audio.audioController.audioURL'
+ }),
+
+ audioProperties:Audio.AudioProperties.design({
+ layout: { top: 40, bottom:0, left: 0, right: 0},
+ audioViewBinding: 'Audio.mainPage.mainPane.container.html5container.audioPlayer'
+ })
+ }),
+ qtcontainer: SC.View.design({
+ layout: { top: 100, left:512, width: 256, bottom: 100 },
+ childViews: 'audioPlayer audioProperties'.w(),
+ audioPlayer:SC.AudioView.design({
+ degradeList: ['quicktime'],
+ layout: { top: 0, centerX:0, width: 200, height: 20},
+ valueBinding: 'Audio.audioController.audioURL'
+ }),
+
+ audioProperties:Audio.AudioProperties.design({
+ layout: { top: 40, bottom:0, left: 0, right: 0},
+ audioViewBinding: 'Audio.mainPage.mainPane.container.qtcontainer.audioPlayer'
+ })
+ }),
+ flashcontainer: SC.View.design({
+ layout: { top: 100, left: 768, width: 256, bottom: 100 },
+ childViews: 'audioPlayer audioProperties'.w(),
+ audioPlayer:SC.AudioView.design({
+ degradeList: ['flash'],
+ layout: { top: 0, centerX:0, width: 200, height: 20},
+ valueBinding: 'Audio.audioController.audioURL'
+ }),
+
+ audioProperties:Audio.AudioProperties.design({
+ layout: { top: 40, bottom:0, left: 0, right: 0},
+ audioViewBinding: 'Audio.mainPage.mainPane.container.flashcontainer.audioPlayer'
+ })
+ })
+
+ })
+
+ })
+
+});
@@ -0,0 +1,113 @@
+// ==========================================================================
+// Project: Audio.AudioProperties
+// Copyright: ©2010 My Company, Inc.
+// ==========================================================================
+/*globals AudioApp */
+
+/** @class
+
+ (Document Your View Here)
+
+ @extends SC.View
+*/
+
+Audio.numberProps=10;
+
+Audio.AudioProperties = SC.View.extend({
+
+ audioView: null,
+ classNames: ['properties'],
+ childViews : 'currentTimeLabel currentTimeValue durationLabel durationValue volumeLabel volumeValue sizeLabel sizeValue loadedDataLabel loadedDataValue pausedLabel pausedValue loadedLabel loadedValue endedLabel endedValue canPlayLabel canPlayValue timeLabel timeValue'.w(),
+
+ currentTimeLabel:SC.LabelView.design({
+ layout:{top: 0, left:0, width: 0.5, height: (1/Audio.numberProps)},
+ textAlign: SC.ALIGN_RIGHT,
+ value: 'Current Time:'
+ }),
+ currentTimeValue:SC.LabelView.design({
+ layout:{top: 0, right:0, width: 0.4, height: (1/Audio.numberProps)},
+ valueBinding: '*owner.audioView.currentTime'
+ }),
+ durationLabel:SC.LabelView.design({
+ layout:{top: (1/Audio.numberProps), left:0, width: 0.5, height: (1/Audio.numberProps)},
+ textAlign: SC.ALIGN_RIGHT,
+ value: 'Duration:'
+ }),
+ durationValue:SC.LabelView.design({
+ layout:{top: (1/Audio.numberProps), right:0, width: 0.4, height: (1/Audio.numberProps)},
+ valueBinding: '*owner.audioView.duration'
+ }),
+ volumeLabel:SC.LabelView.design({
+ layout:{top: (2/Audio.numberProps), left:0, width: 0.5, height: (1/Audio.numberProps)},
+ textAlign: SC.ALIGN_RIGHT,
+ value: 'Volume:'
+ }),
+ volumeValue:SC.LabelView.design({
+ layout:{top: (2/Audio.numberProps), right:0, width: 0.4, height: (1/Audio.numberProps)},
+ valueBinding: '*owner.audioView.volume'
+ }),
+ sizeLabel:SC.LabelView.design({
+ layout:{top: (3/Audio.numberProps), left:0, width: 0.5, height: (1/Audio.numberProps)},
+ textAlign: SC.ALIGN_RIGHT,
+ value: 'Size:'
+ }),
+ sizeValue:SC.LabelView.design({
+ layout:{top: (3/Audio.numberProps), right:0, width: 0.4, height: (1/Audio.numberProps)},
+ valueBinding: '*owner.audioView.size'
+ }),
+ loadedDataLabel:SC.LabelView.design({
+ layout:{top: (4/Audio.numberProps), left:0, width: 0.5, height: (1/Audio.numberProps)},
+ textAlign: SC.ALIGN_RIGHT,
+ value: 'LoadedData:'
+ }),
+ loadedDataValue:SC.LabelView.design({
+ layout:{top: (4/Audio.numberProps), right:0, width: 0.4, height: (1/Audio.numberProps)},
+ valueBinding: '*owner.audioView.loadedTimeRanges'
+ }),
+ pausedLabel:SC.LabelView.design({
+ layout:{top: (5/Audio.numberProps), left:0, width: 0.5, height: (1/Audio.numberProps)},
+ textAlign: SC.ALIGN_RIGHT,
+ value: 'Paused:'
+ }),
+ pausedValue:SC.LabelView.design({
+ layout:{top: (5/Audio.numberProps), right:0, width: 0.4, height: (1/Audio.numberProps)},
+ valueBinding: '*owner.audioView.paused'
+ }),
+ loadedLabel:SC.LabelView.design({
+ layout:{top: (6/Audio.numberProps), left:0, width: 0.5, height: (1/Audio.numberProps)},
+ textAlign: SC.ALIGN_RIGHT,
+ value: 'Loaded:'
+ }),
+ loadedValue:SC.LabelView.design({
+ layout:{top: (6/Audio.numberProps), right:0, width: 0.4, height: (1/Audio.numberProps)},
+ valueBinding: '*owner.audioView.loaded'
+ }),
+ endedLabel:SC.LabelView.design({
+ layout:{top: (7/Audio.numberProps), left:0, width: 0.5, height: (1/Audio.numberProps)},
+ textAlign: SC.ALIGN_RIGHT,
+ value: 'Ended:'
+ }),
+ endedValue:SC.LabelView.design({
+ layout:{top: (7/Audio.numberProps), right:0, width: 0.4, height: (1/Audio.numberProps)},
+ valueBinding: '*owner.audioView.ended'
+ }),
+ canPlayLabel:SC.LabelView.design({
+ layout:{top: (8/Audio.numberProps), left:0, width: 0.5, height: (1/Audio.numberProps)},
+ textAlign: SC.ALIGN_RIGHT,
+ value: 'Can Play:'
+ }),
+ canPlayValue:SC.LabelView.design({
+ layout:{top: (8/Audio.numberProps), right:0, width: 0.4, height: (1/Audio.numberProps)},
+ valueBinding: '*owner.audioView.canPlay'
+ }),
+ timeLabel:SC.LabelView.design({
+ layout:{top: (9/Audio.numberProps), left:0, width: 0.5, height: (1/Audio.numberProps)},
+ textAlign: SC.ALIGN_RIGHT,
+ value: 'Time:'
+ }),
+ timeValue:SC.LabelView.design({
+ layout:{top: (9/Audio.numberProps), right:0, width: 0.4, height: (1/Audio.numberProps)},
+ valueBinding: '*owner.audioView.time'
+ })
+});
+
Oops, something went wrong.

0 comments on commit a105afe

Please sign in to comment.