How do I get an audio object from a URL in Google Apps Script?
I'm trying to get the properties (e.g. its duration) of a MP3 file at a URL in a Google Apps Script. The following code gets an object, but as best I can tell, the resulting object is not an audio object.
function loadMusic(url) {
if (url == undefined) {
url = "http://traffic.libsyn.com/socialmediasec/Weekly_Blaze_E43.mp3";
};
var audio = UrlFetchApp.fetch(url).getAs("audio/mpeg");
return audio;
};
Doing this kind of thing in a webpage is simple using the Audio object (see W3Schools' documentation (link). Ideally, I would like to do something similar to this (link) except by referencing a URL instead of a DOM element. Is this possible?
javascript google-apps-script blob html5-audio
add a comment |
I'm trying to get the properties (e.g. its duration) of a MP3 file at a URL in a Google Apps Script. The following code gets an object, but as best I can tell, the resulting object is not an audio object.
function loadMusic(url) {
if (url == undefined) {
url = "http://traffic.libsyn.com/socialmediasec/Weekly_Blaze_E43.mp3";
};
var audio = UrlFetchApp.fetch(url).getAs("audio/mpeg");
return audio;
};
Doing this kind of thing in a webpage is simple using the Audio object (see W3Schools' documentation (link). Ideally, I would like to do something similar to this (link) except by referencing a URL instead of a DOM element. Is this possible?
javascript google-apps-script blob html5-audio
This may be an issue with the fact that Apps Script is still very underdeveloped and incapable of a lot of standard JavaScript functionality. I would suggest not using Apps Script; just use the Google APIs with Node.js or Python or something.
– e.maguire
Nov 20 at 2:55
@e.maguire "Audio object" and the duration property aren't part of the JavaScript specification but they are part of the web apis. Ref. developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/…
– Rubén
Nov 20 at 3:11
@e.maguire The thing is that I am doing this in a custom function in Google Sheets. Is it possible to use the Google APIs with Node.J's or Python in Google Sheets?
– tlewis3348
Nov 20 at 10:41
add a comment |
I'm trying to get the properties (e.g. its duration) of a MP3 file at a URL in a Google Apps Script. The following code gets an object, but as best I can tell, the resulting object is not an audio object.
function loadMusic(url) {
if (url == undefined) {
url = "http://traffic.libsyn.com/socialmediasec/Weekly_Blaze_E43.mp3";
};
var audio = UrlFetchApp.fetch(url).getAs("audio/mpeg");
return audio;
};
Doing this kind of thing in a webpage is simple using the Audio object (see W3Schools' documentation (link). Ideally, I would like to do something similar to this (link) except by referencing a URL instead of a DOM element. Is this possible?
javascript google-apps-script blob html5-audio
I'm trying to get the properties (e.g. its duration) of a MP3 file at a URL in a Google Apps Script. The following code gets an object, but as best I can tell, the resulting object is not an audio object.
function loadMusic(url) {
if (url == undefined) {
url = "http://traffic.libsyn.com/socialmediasec/Weekly_Blaze_E43.mp3";
};
var audio = UrlFetchApp.fetch(url).getAs("audio/mpeg");
return audio;
};
Doing this kind of thing in a webpage is simple using the Audio object (see W3Schools' documentation (link). Ideally, I would like to do something similar to this (link) except by referencing a URL instead of a DOM element. Is this possible?
javascript google-apps-script blob html5-audio
javascript google-apps-script blob html5-audio
edited Nov 20 at 3:58
Rubén
10k43265
10k43265
asked Nov 20 at 2:50
tlewis3348
1491316
1491316
This may be an issue with the fact that Apps Script is still very underdeveloped and incapable of a lot of standard JavaScript functionality. I would suggest not using Apps Script; just use the Google APIs with Node.js or Python or something.
– e.maguire
Nov 20 at 2:55
@e.maguire "Audio object" and the duration property aren't part of the JavaScript specification but they are part of the web apis. Ref. developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/…
– Rubén
Nov 20 at 3:11
@e.maguire The thing is that I am doing this in a custom function in Google Sheets. Is it possible to use the Google APIs with Node.J's or Python in Google Sheets?
– tlewis3348
Nov 20 at 10:41
add a comment |
This may be an issue with the fact that Apps Script is still very underdeveloped and incapable of a lot of standard JavaScript functionality. I would suggest not using Apps Script; just use the Google APIs with Node.js or Python or something.
– e.maguire
Nov 20 at 2:55
@e.maguire "Audio object" and the duration property aren't part of the JavaScript specification but they are part of the web apis. Ref. developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/…
– Rubén
Nov 20 at 3:11
@e.maguire The thing is that I am doing this in a custom function in Google Sheets. Is it possible to use the Google APIs with Node.J's or Python in Google Sheets?
– tlewis3348
Nov 20 at 10:41
This may be an issue with the fact that Apps Script is still very underdeveloped and incapable of a lot of standard JavaScript functionality. I would suggest not using Apps Script; just use the Google APIs with Node.js or Python or something.
– e.maguire
Nov 20 at 2:55
This may be an issue with the fact that Apps Script is still very underdeveloped and incapable of a lot of standard JavaScript functionality. I would suggest not using Apps Script; just use the Google APIs with Node.js or Python or something.
– e.maguire
Nov 20 at 2:55
@e.maguire "Audio object" and the duration property aren't part of the JavaScript specification but they are part of the web apis. Ref. developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/…
– Rubén
Nov 20 at 3:11
@e.maguire "Audio object" and the duration property aren't part of the JavaScript specification but they are part of the web apis. Ref. developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/…
– Rubén
Nov 20 at 3:11
@e.maguire The thing is that I am doing this in a custom function in Google Sheets. Is it possible to use the Google APIs with Node.J's or Python in Google Sheets?
– tlewis3348
Nov 20 at 10:41
@e.maguire The thing is that I am doing this in a custom function in Google Sheets. Is it possible to use the Google APIs with Node.J's or Python in Google Sheets?
– tlewis3348
Nov 20 at 10:41
add a comment |
1 Answer
1
active
oldest
votes
UrlFetchApp.fetch(url).getAs("audio/mpeg")
returns a blob object. Google Apps Script doesn't has an specific class for "audio objects". If you save the file to Google Drive, then you could use the Google Apps Script advanced service for Google Drive to get the metadata from the file but depending on the specific details of what you are looking for, it could be easier to use client-side code to get the DOM audio object and the related properties like the audio duration.
I'm trying to get this information in a custom function in Google Sheets. Is it possible to use client-side code to get the DOM audio object from inside a custom function? I could certainly do as you suggest and add the file to Google Drive, but because I'm trying to get this information for all the episodes from several different podcasts over the past year, my suspicion would be that it would be pretty slow and eat up my Drive storage space pretty quickly. If there's no other option, I may be able to make it work, but I was hoping for a simpler solution.
– tlewis3348
Nov 20 at 10:49
3
Custom function can't access client-side code but client-side code can update cells. Please checkout developers.google.com/apps-script/guides/sheets/functions and developers.google.com/apps-script/guides/html. If you need further help, post a new question.
– Rubén
Nov 20 at 17:29
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385514%2fhow-do-i-get-an-audio-object-from-a-url-in-google-apps-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
UrlFetchApp.fetch(url).getAs("audio/mpeg")
returns a blob object. Google Apps Script doesn't has an specific class for "audio objects". If you save the file to Google Drive, then you could use the Google Apps Script advanced service for Google Drive to get the metadata from the file but depending on the specific details of what you are looking for, it could be easier to use client-side code to get the DOM audio object and the related properties like the audio duration.
I'm trying to get this information in a custom function in Google Sheets. Is it possible to use client-side code to get the DOM audio object from inside a custom function? I could certainly do as you suggest and add the file to Google Drive, but because I'm trying to get this information for all the episodes from several different podcasts over the past year, my suspicion would be that it would be pretty slow and eat up my Drive storage space pretty quickly. If there's no other option, I may be able to make it work, but I was hoping for a simpler solution.
– tlewis3348
Nov 20 at 10:49
3
Custom function can't access client-side code but client-side code can update cells. Please checkout developers.google.com/apps-script/guides/sheets/functions and developers.google.com/apps-script/guides/html. If you need further help, post a new question.
– Rubén
Nov 20 at 17:29
add a comment |
UrlFetchApp.fetch(url).getAs("audio/mpeg")
returns a blob object. Google Apps Script doesn't has an specific class for "audio objects". If you save the file to Google Drive, then you could use the Google Apps Script advanced service for Google Drive to get the metadata from the file but depending on the specific details of what you are looking for, it could be easier to use client-side code to get the DOM audio object and the related properties like the audio duration.
I'm trying to get this information in a custom function in Google Sheets. Is it possible to use client-side code to get the DOM audio object from inside a custom function? I could certainly do as you suggest and add the file to Google Drive, but because I'm trying to get this information for all the episodes from several different podcasts over the past year, my suspicion would be that it would be pretty slow and eat up my Drive storage space pretty quickly. If there's no other option, I may be able to make it work, but I was hoping for a simpler solution.
– tlewis3348
Nov 20 at 10:49
3
Custom function can't access client-side code but client-side code can update cells. Please checkout developers.google.com/apps-script/guides/sheets/functions and developers.google.com/apps-script/guides/html. If you need further help, post a new question.
– Rubén
Nov 20 at 17:29
add a comment |
UrlFetchApp.fetch(url).getAs("audio/mpeg")
returns a blob object. Google Apps Script doesn't has an specific class for "audio objects". If you save the file to Google Drive, then you could use the Google Apps Script advanced service for Google Drive to get the metadata from the file but depending on the specific details of what you are looking for, it could be easier to use client-side code to get the DOM audio object and the related properties like the audio duration.
UrlFetchApp.fetch(url).getAs("audio/mpeg")
returns a blob object. Google Apps Script doesn't has an specific class for "audio objects". If you save the file to Google Drive, then you could use the Google Apps Script advanced service for Google Drive to get the metadata from the file but depending on the specific details of what you are looking for, it could be easier to use client-side code to get the DOM audio object and the related properties like the audio duration.
answered Nov 20 at 3:53
Rubén
10k43265
10k43265
I'm trying to get this information in a custom function in Google Sheets. Is it possible to use client-side code to get the DOM audio object from inside a custom function? I could certainly do as you suggest and add the file to Google Drive, but because I'm trying to get this information for all the episodes from several different podcasts over the past year, my suspicion would be that it would be pretty slow and eat up my Drive storage space pretty quickly. If there's no other option, I may be able to make it work, but I was hoping for a simpler solution.
– tlewis3348
Nov 20 at 10:49
3
Custom function can't access client-side code but client-side code can update cells. Please checkout developers.google.com/apps-script/guides/sheets/functions and developers.google.com/apps-script/guides/html. If you need further help, post a new question.
– Rubén
Nov 20 at 17:29
add a comment |
I'm trying to get this information in a custom function in Google Sheets. Is it possible to use client-side code to get the DOM audio object from inside a custom function? I could certainly do as you suggest and add the file to Google Drive, but because I'm trying to get this information for all the episodes from several different podcasts over the past year, my suspicion would be that it would be pretty slow and eat up my Drive storage space pretty quickly. If there's no other option, I may be able to make it work, but I was hoping for a simpler solution.
– tlewis3348
Nov 20 at 10:49
3
Custom function can't access client-side code but client-side code can update cells. Please checkout developers.google.com/apps-script/guides/sheets/functions and developers.google.com/apps-script/guides/html. If you need further help, post a new question.
– Rubén
Nov 20 at 17:29
I'm trying to get this information in a custom function in Google Sheets. Is it possible to use client-side code to get the DOM audio object from inside a custom function? I could certainly do as you suggest and add the file to Google Drive, but because I'm trying to get this information for all the episodes from several different podcasts over the past year, my suspicion would be that it would be pretty slow and eat up my Drive storage space pretty quickly. If there's no other option, I may be able to make it work, but I was hoping for a simpler solution.
– tlewis3348
Nov 20 at 10:49
I'm trying to get this information in a custom function in Google Sheets. Is it possible to use client-side code to get the DOM audio object from inside a custom function? I could certainly do as you suggest and add the file to Google Drive, but because I'm trying to get this information for all the episodes from several different podcasts over the past year, my suspicion would be that it would be pretty slow and eat up my Drive storage space pretty quickly. If there's no other option, I may be able to make it work, but I was hoping for a simpler solution.
– tlewis3348
Nov 20 at 10:49
3
3
Custom function can't access client-side code but client-side code can update cells. Please checkout developers.google.com/apps-script/guides/sheets/functions and developers.google.com/apps-script/guides/html. If you need further help, post a new question.
– Rubén
Nov 20 at 17:29
Custom function can't access client-side code but client-side code can update cells. Please checkout developers.google.com/apps-script/guides/sheets/functions and developers.google.com/apps-script/guides/html. If you need further help, post a new question.
– Rubén
Nov 20 at 17:29
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385514%2fhow-do-i-get-an-audio-object-from-a-url-in-google-apps-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This may be an issue with the fact that Apps Script is still very underdeveloped and incapable of a lot of standard JavaScript functionality. I would suggest not using Apps Script; just use the Google APIs with Node.js or Python or something.
– e.maguire
Nov 20 at 2:55
@e.maguire "Audio object" and the duration property aren't part of the JavaScript specification but they are part of the web apis. Ref. developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/…
– Rubén
Nov 20 at 3:11
@e.maguire The thing is that I am doing this in a custom function in Google Sheets. Is it possible to use the Google APIs with Node.J's or Python in Google Sheets?
– tlewis3348
Nov 20 at 10:41