Skip to content

Commit

Permalink
Merge pull request #12 from choorp/luneos-dev
Browse files Browse the repository at this point in the history
Luneos dev
  • Loading branch information
Garrett committed Mar 12, 2016
2 parents ae46c6a + f575c4a commit da2cc47
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
6 changes: 5 additions & 1 deletion fxos/manifest.webapp
Expand Up @@ -2,7 +2,7 @@
"name": "FoxCasts",

"description": "A fully-featured podcast app for your FirefoxOS device.",
"version": "1.4.0",
"version": "1.4.1",
"launch_path": "/index.html",
"icons": {
"256": "/assets/icon-256.png",
Expand Down Expand Up @@ -34,6 +34,10 @@
"access": "readwrite",
"description": "Required to read and write podcasts episodes."
},
"device-storage:videos": {
"access": "readwrite",
"description": "Required to read and write podcasts episodes."
},
"device-storage:sdcard": {
"access": "readwrite",
"description": "Required to read and write podcasts episodes to external storage."
Expand Down
2 changes: 1 addition & 1 deletion luneos/appinfo.json
@@ -1,7 +1,7 @@
{
"title": "FoxCasts",
"id": "com.choorp.app.foxcasts",
"version": "1.4.0",
"version": "1.4.1",
"vendor": "Garrett Downs",
"vendor_url": "https://github.com/choorp/foxcasts",
"type": "web",
Expand Down
2 changes: 1 addition & 1 deletion source/views/Player.js
Expand Up @@ -88,7 +88,7 @@ enyo.kind({
if (this.episode.downloaded == "true") {
this.log("Playing local file.");
if (typeof this.episode.localUrl == "string") {
StorageManager.get(this, this.episode.localUrl);
StorageManager.get(this, this.episode);
} else {
// Handle old storage method (blob)
this.startEpisode(this.episode.localUrl);
Expand Down
8 changes: 4 additions & 4 deletions source/views/PodcastDetail.js
Expand Up @@ -71,9 +71,9 @@ enyo.kind({
this.$.episodes.render();
},
stream: function(inSender, inEvent) {
this.log("activeEpisode", this.activeEpisode);
this.log("activeEpisode", this.activeEpisode.episode);

this.doStream(this.activeEpisode);
this.doStream(this.activeEpisode.episode);
this.$.popup.hide();
},
resume: function(inSender, episode) {
Expand Down Expand Up @@ -110,8 +110,8 @@ enyo.kind({
return(e);
},
showPopup: function(inSender, inEvent) {
this.activeEpisode = inSender.episode;
var e = this.activeEpisode;
this.activeEpisode = inSender;
var e = this.activeEpisode.episode;
this.$.episodeTitle.setContent(e.title);

this.$.btnResume.setShowing(false);
Expand Down
33 changes: 25 additions & 8 deletions source/views/Services.js
Expand Up @@ -42,9 +42,20 @@ var StorageManager = [];

StorageManager.store = function(_this, sender, blob) {
console.log("ready to store file...");
var storage = navigator.getDeviceStorage("music");
console.log(storage);
var name = sender.episode.name + sender.episode.date + ".mp3";
console.log(sender);

var storage, name;

if (sender.episode.type == "video/mp4") {
storage = navigator.getDeviceStorage("videos");
console.log(storage);
name = sender.episode.name + sender.episode.date + ".mp4";
} else {
storage = navigator.getDeviceStorage("music");
console.log(storage);
name = sender.episode.name + sender.episode.date + ".mp3";
}


var request = storage.addNamed(blob, name);

Expand All @@ -56,19 +67,25 @@ StorageManager.store = function(_this, sender, blob) {
};

// An error typically occur if a file with the same name already exist
request.onerror = function () {
request.onerror = function (e) {
console.log(e);
console.warn('Unable to write the file');
alert("Unable to write file. A file with the same name may already exist.");
};
};

StorageManager.get = function(_this, name) {
StorageManager.get = function(_this, episode) {
console.log("ready to get file...");

var storage = navigator.getDeviceStorage("music");
console.log(storage);
var storage;

if (episode.type == "video/mp4") {
storage = navigator.getDeviceStorage("videos");
} else {
storage = navigator.getDeviceStorage("music");
}

var request = storage.get(name);
var request = storage.get(episode.localUrl);

request.onsuccess = function () {
var file = this.result;
Expand Down

0 comments on commit da2cc47

Please sign in to comment.