We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Trying to follow this post: https://forum.processing.org/two/discussion/18109/how-can-i-clone-an-image-object (also https://thimbleprojects.org/gotoloop/97931/sketch.js )
I tried to use sketchpad.cc but I gave up as it doesn't allow me to load mp3 files to their assets folder.
The idea is to load a sound file but I am having issues accessing the files from the assets source as demo by @GoToLoop in previous posts. I am not sure what I am doing wrong or what I am missing. I am trying images and no success. What I am missing?
This is what I have:
"use strict";
const SUBFOLDER = 'assets/';
let original;
function preload(){
original = loadImage('http://"+"ashemag.com/wp-content/uploads/2016/03/Classy-Sunglasses-for-summer-03-300x300.jpg');}
//NOTICE I also tried to loaded from hte resource folder
//original = loadImage(SUBFOLDER + 'original.jpg');
}
function setup() {
createCanvas(original.width, original.height);
}
function draw() {
background(original);
}
My html file is like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Made with Thimble</title>
<link rel="stylesheet" href="style.css">
<script async src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/p5.js"></script>
<!--<script language="javascript" type="text/javascript" src="https://"+"cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/addons/p5.dom.js"></script>
<script async language="javascript" type="text/javascript" src="https://"+"cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/addons/p5.sound.js"></script>-->
<script defer src="sketch.js"> </script>
</head>
<body>
<h1>Welcome to Thimble</h1>
<div id="supercanvas"></div>
<p>Make something <strong>amazing</strong> with the web!</p>
</body>
So when I try running the js + html, I get a "Loading..." but nothing happens. Is this CORS related despite I am running in thimbleproject?
CORS relate comment: https://forum.processing.org/two/discussion/comment/95739/#Comment_95739
Kf
Additional but not relevant: https://forum.processing.org/two/discussion/21532/dom-interfering-with-sketch-container/p1
Answers
https://OpenProcessing.org/sketch/create allows .mp3 and other media asset uploads. :-bd
@GoToLoop Do you have any other settings in thimbleproject? I am scratching my head... why it didn't work? Can you also comment on codepen?
Kf
Media upload is a paid "pro" feature at CodePen and other similar JS host services. :-<
So unless you wanna pay for "pro" features, forget about hosting sketches + media files together in those sites. :-@
@kfrajer -- I haven't used Thimble, but did you try uploading the media file directly to the thimble site, using the Files+ toolbar button on the left side? That should get around the CORS -- it seems to work in the Thimble homepage demos....
That http://ThimbleProjects.org/gotoloop/97931/ sketch was particularly very hard to pull off at Thimble! #:-S
If you insist on using Thimble to host sketches together w/ media files, have them in the root folder.
Or else, prepare to suffer a lot! >:)
Or simply go w/ https://OpenProcessing.org/sketch/create. O:-)
Other options are GitHub's gh-pages:
https://help.GitHub.com/articles/configuring-a-publishing-source-for-github-pages/
And my fav now: Gist.GitHub.com + Bl.ocks.org. Two examples below: :bz
Instructions here: https://Bl.ocks.org/-/about ;)
Be aware that Gist hosting doesn't allow subfolders!
For that, use gh-pages. Or keep trying to achieve that on Thimble like I did once. >:)
1 more detail I've forgotten to mention for Gist: :|
In order to update non-text files there, you're gonna need to install & use Git: #-o
https://Git-SCM.com/
@jeremydouglass I loaded the file in the webpage but it didn't work which I was confused because I have seen previous basic examples done the same way before. I am just tipping toeing in incorporating p5.js in a website and i will take me few trial and errors to get it going while i get more experience on this.
Thanks @GoToLoop for your comments, very appreciated. I might try more Thimble today if time permits. Git sounds also as one of my next options.
Kf
So if I load the images directly using the html tag img, it works fine. I am having problems loading it from the javascript files. I read online that when I get a 404 error, file not found, the site caches the error for about one hour. :-w Waiting....
Kf
Ok, so if I publish the project, any image loaded in the js side works. It seems the problem is only in preview mode, while working in the project. Done for today... I try mp3 tomorrow.
Kf
I created a ticket: https://github.com/mozilla/thimble.mozilla.org/issues/2036
Related link: https://github.com/mozilla/thimble.mozilla.org/issues/1535
So the problem is known and they are working on it. Not possible to load the images when loaded from a js script and it seems it is due to parsing issues to identify the links. Good news is that they are working in a possible solution: https://github.com/mozilla/brackets/pull/725
Kf