This repository was archived by the owner on Feb 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
106 lines (100 loc) · 3.35 KB
/
Copy pathindex.html
File metadata and controls
106 lines (100 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SoundTrade</title>
<style>
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
font-family: Arial, sans-serif;
background-color: #282c34;
color: white;
text-align: center;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
margin-top: 10px;
}
input[type="file"] {
padding: 10px;
font-size: 16px;
margin-bottom: 10px;
width: 80%;
max-width: 300px;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<div id="upload-section">
<h1>Welcome to SoundTrade!</h1>
<p>Upload your aggr.trade workspace JSON file:</p>
<input type="file" id="workspace-file" accept=".json" />
<button onclick="loadWorkspace()">LFG! 🚀</button>
</div>
<div id="audio-section" class="hidden">
<h1>Streaming from your Workspace</h1>
<button onclick="toggleAudio()">Play/Stop Audio</button>
</div>
<script>
let audioPlaying = false;
let audioContext;
let audioElement;
function loadWorkspace() {
const fileInput = document.getElementById('workspace-file');
const file = fileInput.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(event) {
const content = event.target.result;
try {
const workspaceConfig = JSON.parse(content);
console.log('Workspace loaded:', workspaceConfig);
document.getElementById('upload-section').classList.add('hidden');
document.getElementById('audio-section').classList.remove('hidden');
// You can now use the workspaceConfig to set up your streaming as needed.
} catch (error) {
alert('Error parsing JSON file. Please make sure it is a valid workspace file.');
}
};
reader.readAsText(file);
} else {
alert('Please upload a workspace JSON file.');
}
}
function toggleAudio() {
if (audioPlaying) {
stopAudio();
} else {
playAudio();
}
}
function playAudio() {
if (!audioContext) {
audioContext = new (window.AudioContext || window.webkitAudioContext)();
audioElement = new Audio(`https://aggr.trade/your-default-workspace`);
const track = audioContext.createMediaElementSource(audioElement);
track.connect(audioContext.destination);
}
audioElement.play();
audioPlaying = true;
}
function stopAudio() {
if (audioElement) {
audioElement.pause();
audioPlaying = false;
}
}
</script>
</body>
</html>