Skip to content

Commit

Permalink
my sound board app
Browse files Browse the repository at this point in the history
  • Loading branch information
cfjedimaster committed Jul 30, 2015
1 parent 0e507cf commit eb9f85f
Show file tree
Hide file tree
Showing 79 changed files with 122,580 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mysoundboard/.gitignore
@@ -0,0 +1,6 @@
# Specifies intentionally untracked files to ignore when using Git
# http://git-scm.com/docs/gitignore

node_modules/
platforms/
plugins/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mysoundboard/resources/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mysoundboard/resources/ios/icon/icon-40.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mysoundboard/resources/ios/icon/icon-40@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mysoundboard/resources/ios/icon/icon-50.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mysoundboard/resources/ios/icon/icon-50@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mysoundboard/resources/ios/icon/icon-60.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mysoundboard/resources/ios/icon/icon-60@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mysoundboard/resources/ios/icon/icon-60@3x.png
Binary file added mysoundboard/resources/ios/icon/icon-72.png
Binary file added mysoundboard/resources/ios/icon/icon-72@2x.png
Binary file added mysoundboard/resources/ios/icon/icon-76.png
Binary file added mysoundboard/resources/ios/icon/icon-76@2x.png
Binary file added mysoundboard/resources/ios/icon/icon-small.png
Binary file added mysoundboard/resources/ios/icon/icon-small@2x.png
Binary file added mysoundboard/resources/ios/icon/icon-small@3x.png
Binary file added mysoundboard/resources/ios/icon/icon.png
Binary file added mysoundboard/resources/ios/icon/icon@2x.png
Binary file added mysoundboard/resources/splash.png
13 changes: 13 additions & 0 deletions mysoundboard/www/css/angular-csp.css
@@ -0,0 +1,13 @@
/* Include this file in your html if you are using the CSP mode. */

@charset "UTF-8";

[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak],
.ng-cloak, .x-ng-cloak,
.ng-hide:not(.ng-hide-animate) {
display: none !important;
}

ng\:form {
display: block;
}
1 change: 1 addition & 0 deletions mysoundboard/www/css/style.css
@@ -0,0 +1 @@
/* Empty. Add your own CSS if you like */
Binary file added mysoundboard/www/img/ionic.png
34 changes: 34 additions & 0 deletions mysoundboard/www/index.html
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<meta http-equiv="Content-Security-Policy"
content="default-src 'self' data: gap: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-eval' 'unsafe-inline';">
<title></title>

<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/angular-csp.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
</head>
<body ng-app="mysoundboard">

<ion-nav-bar class="bar-stable">
<ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar>

<ion-nav-view></ion-nav-view>
</body>
</html>
36 changes: 36 additions & 0 deletions mysoundboard/www/js/app.js
@@ -0,0 +1,36 @@
angular.module('mysoundboard', ['ionic', 'mysoundboard.controllers', 'mysoundboard.services'])

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);

}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleLightContent();
}
});
})

.config(function($stateProvider, $urlRouterProvider) {

$stateProvider

.state('home', {
url: '/home',
controller: 'HomeCtrl',
templateUrl: 'templates/home.html'
})
.state('new', {
url:'/new',
controller: 'RecordCtrl',
templateUrl: 'templates/new.html'
});


// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/home');

});
129 changes: 129 additions & 0 deletions mysoundboard/www/js/controllers.js
@@ -0,0 +1,129 @@
angular.module('mysoundboard.controllers', [])

.controller('HomeCtrl', function($scope, Sounds, $ionicPlatform) {

var getSounds = function() {
console.log('getSounds called');
Sounds.get().then(function(sounds) {
console.dir(sounds);
$scope.sounds = sounds;
});
}

$scope.$on('$ionicView.enter', function(){
console.log('enter');
getSounds();
});

$scope.play = function(x) {
console.log('play', x);
Sounds.play(x);
}

$scope.delete = function(x) {
console.log('delete', x);
Sounds.delete(x).then(function() {
getSounds();
});
}

$scope.cordova = {loaded:false};
$ionicPlatform.ready(function() {
$scope.$apply(function() {
$scope.cordova.loaded = true;
});
});

})
.controller('RecordCtrl', function($scope, Sounds, $state, $ionicHistory) {

$scope.sound = {name:""};

$scope.saveSound = function() {
console.log('trying to save '+$scope.sound.name);

//Simple error checking
if($scope.sound.name === "") {
navigator.notification.alert("Name this sound first.", null, "Error");
return;
}

if(!$scope.sound.file) {
navigator.notification.alert("Record a sound first.", null, "Error");
return;
}

/*
begin the copy to persist location
first, this path below is persistent on both ios and and
*/
var loc = cordova.file.dataDirectory;
/*
but now we have an issue with file name. so let's use the existing extension,
but a unique filename based on seconds since epoch
*/
var extension = $scope.sound.file.split(".").pop();
var filepart = Date.now();
var filename = filepart + "." + extension;
console.log("new filename is "+filename);

window.resolveLocalFileSystemURL(loc, function(d) {
window.resolveLocalFileSystemURL($scope.sound.file, function(fe) {
fe.copyTo(d, filename, function(e) {
console.log('success inc opy');
console.dir(e);
$scope.sound.file = e.nativeURL;
$scope.sound.path = e.fullPath;

Sounds.save($scope.sound).then(function() {
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go("home");
});

}, function(e) {
console.log('error in coipy');console.dir(e);
});
}, function(e) {
console.log("error in inner bullcrap");
console.dir(e);
});


}, function(e) {
console.log('error in fs');console.dir(e);
});


}

var captureError = function(e) {
console.log('captureError' ,e);
}

var captureSuccess = function(e) {
console.log('captureSuccess');console.dir(e);
$scope.sound.file = e[0].localURL;
$scope.sound.filePath = e[0].fullPath;
}

$scope.record = function() {
navigator.device.capture.captureAudio(
captureSuccess,captureError,{duration:10});
}

$scope.play = function() {
if(!$scope.sound.file) {
navigator.notification.alert("Record a sound first.", null, "Error");
return;
}
var media = new Media($scope.sound.file, function(e) {
media.release();
}, function(err) {
console.log("media err", err);
});
media.play();
}
});
69 changes: 69 additions & 0 deletions mysoundboard/www/js/services.js
@@ -0,0 +1,69 @@
angular.module('mysoundboard.services', [])

.factory('Sounds', function($q) {

var deleteSound = function(x) {
console.log("calling deleteSound");
var deferred = $q.defer();
getSounds().then(function(sounds) {
sounds.splice(x,1);
localStorage.mysoundboard = JSON.stringify(sounds);
deferred.resolve();
});

return deferred.promise;

}

var getSounds = function() {
var deferred = $q.defer();
var sounds = [];

if(localStorage.mysoundboard) {
sounds = JSON.parse(localStorage.mysoundboard);
}
deferred.resolve(sounds);

return deferred.promise;
}

var playSound = function(x) {
getSounds().then(function(sounds) {
var sound = sounds[x];

/*
Ok, so on Android, we just work.
On iOS, we need to rewrite to ../Library/NoCloud/FILE'
*/
var mediaUrl = sound.file;
if(device.platform.indexOf("iOS") >= 0) {
mediaUrl = "../Library/NoCloud/" + mediaUrl.split("/").pop();
}
var media = new Media(mediaUrl, function(e) {
media.release();
}, function(err) {
console.log("media err", err);
});
media.play();
});
}

var saveSound = function(s) {
console.log("calling saveSound");
var deferred = $q.defer();
getSounds().then(function(sounds) {
sounds.push(s);
localStorage.mysoundboard = JSON.stringify(sounds);
deferred.resolve();
});

return deferred.promise;
}

return {
get:getSounds,
save:saveSound,
delete:deleteSound,
play:playSound
};
});
7,690 changes: 7,690 additions & 0 deletions mysoundboard/www/lib/ionic/css/ionic.css

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions mysoundboard/www/lib/ionic/css/ionic.min.css

Large diffs are not rendered by default.

Binary file added mysoundboard/www/lib/ionic/fonts/ionicons.eot
Binary file not shown.

0 comments on commit eb9f85f

Please sign in to comment.