Skip to content
Snippets Groups Projects
Commit db0d287b authored by ismcarb's avatar ismcarb
Browse files

Cambios, y metadata?¿

parent c9d753c2
No related branches found
No related tags found
No related merge requests found
......@@ -4,14 +4,13 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="0c5e7f40-d6e0-4cdf-8175-c288dac24af5" name="Changes" comment="Cambios cortos">
<change afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlayList.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlayRandomSong.java" afterDir="false" />
<list default="true" id="0c5e7f40-d6e0-4cdf-8175-c288dac24af5" name="Changes" comment="Final ultimo lab">
<change afterPath="$PROJECT_DIR$/src/spotify/rmi/client/CompleteMetadata.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/spotify/rmi/client/SpotifyClientImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/client/SpotifyClientImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/spotify/rmi/client/SpotifyClientImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/SpotifyClientImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlayList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlayList.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlayRandomSong.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlayRandomSong.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlaySong.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/client/stream/unit/PlaySong.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/spotify/rmi/server/Launcher.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/server/Launcher.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/spotify/rmi/server/SpotifyServerImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/rmi/server/SpotifyServerImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/spotify/stream/ServerStream.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/spotify/stream/ServerStream.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
......@@ -43,31 +42,31 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Application.Client.executor": "Run",
"Application.Launcher.executor": "Run",
"Application.PlayList.executor": "Run",
"Application.PlayRandomSong.executor": "Run",
"Application.PlaySong.executor": "Run",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "master",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "/home/ismael/IdeaProjects/practicasdis2/src/spotify",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"project.structure.last.edited": "Modules",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.0",
"settings.editor.selected.configurable": "preferences.lookFeel",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Application.Client.executor&quot;: &quot;Run&quot;,
&quot;Application.Launcher.executor&quot;: &quot;Run&quot;,
&quot;Application.PlayList.executor&quot;: &quot;Run&quot;,
&quot;Application.PlayRandomSong.executor&quot;: &quot;Run&quot;,
&quot;Application.PlaySong.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/ismael/IdeaProjects/practicasdis2/src/spotify&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
&quot;project.structure.proportion&quot;: &quot;0.0&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.0&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/spotify" />
......@@ -107,7 +106,8 @@
<workItem from="1716058954613" duration="24000" />
<workItem from="1716193421391" duration="5004000" />
<workItem from="1716289481350" duration="3207000" />
<workItem from="1716300799328" duration="6801000" />
<workItem from="1716300799328" duration="6999000" />
<workItem from="1716309405427" duration="3058000" />
</task>
<task id="LOCAL-00001" summary="l">
<option name="closed" value="true" />
......@@ -157,7 +157,15 @@
<option name="project" value="LOCAL" />
<updated>1716300930094</updated>
</task>
<option name="localTasksCounter" value="7" />
<task id="LOCAL-00007" summary="Final ultimo lab">
<option name="closed" value="true" />
<created>1716307787287</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1716307787287</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
......@@ -181,6 +189,7 @@
<MESSAGE value="Modulo 1" />
<MESSAGE value="Modulo 2" />
<MESSAGE value="Cambios cortos" />
<option name="LAST_COMMIT_MESSAGE" value="Cambios cortos" />
<MESSAGE value="Final ultimo lab" />
<option name="LAST_COMMIT_MESSAGE" value="Final ultimo lab" />
</component>
</project>
\ No newline at end of file
package spotify.rmi.client;
import java.util.ArrayList;
import java.util.Random;
import spotify.media.Media;
public class CompleteMetadata {
public static void main(String[] args) {
List<Media> mediaList = new ArrayList<>();
// Suponemos que tienes una lista de objetos Media ya creada
for (int i = 0; i < 10; i++) {
mediaList.add(new Media());
}
Random random = new Random();
String[] predefinedComments = {
"Me encanta esta cancion!!!", "De lo mejor que he escuchado", "Muy buena", "No es de mi gusto :(", "Fantastica", "Podria ser mejor, sobretodo la letra es muuuuuy mejorable",
"Buen ritmo, y mejor cantante imposible", "Letra de otro mundo!", "Esta bien", "La disfruto cada vez que la esucho", "Increible ritmo",
"No me gusta", "Bastante buena", "Demasiado fuerte...", "¡Increible!", "Suave, pero mola", "Melodia pegadiza", "Muy repetitiva, a ver si se inventan algo mejor",
"Me encantan las voces de fondo, de pelicula!", "Aburrida..."
};
for (Media media : mediaList) {
// Añadir likes aleatorios entre 0 y 1000
int likes = random.nextInt(1001);
for (int i = 0; i < likes; i++) {
media.addLike();
}
// 30% de probabilidad de contenido adulto
if (random.nextDouble() < 0.3) {
media.tagAdultContent(true);
}
// Añadir de 0 a 20 comentarios aleatorios
int numComments = random.nextInt(21);
for (int i = 0; i < numComments; i++) {
String comment = predefinedComments[random.nextInt(predefinedComments.length)];
media.addComment(comment);
}
// Añadir un número aleatorio de puntuaciones entre 0 y 1000
int numScores = random.nextInt(1001);
for (int i = 0; i < numScores; i++) {
double score = random.nextDouble() * 5; // Puntuación entre 0 y 5
media.addScore(score);
}
}
System.out.println("Relleno de metadatos completado.\n");
}
}
package spotify.rmi.client;
package spotify.rmi.client.stream;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
......
package spotify.rmi.client.stream.unit;
import spotify.rmi.client.SpotifyClientImpl;
import spotify.rmi.client.stream.SpotifyClientImpl;
import spotify.rmi.common.Spotify;
import spotify.rmi.common.SpotifyServer;
......@@ -12,6 +12,8 @@ public class PlayList {
public static void main(String [ ] args) {
String host = "localHost";
Scanner scanner = new Scanner(System.in);
try {
SpotifyServer orServer = (SpotifyServer) Naming.lookup("rmi://"+host+"/ObjetoSpotify");
Spotify or = (Spotify) Naming.lookup("rmi://"+host+"/ObjetoSpotify");
......@@ -35,28 +37,31 @@ public class PlayList {
"(2) saltar y saber la siguiente\n" +
"(3) salir del programa\n";
Scanner scanner = new Scanner(System.in);
while(!termina){
System.out.println("La cancion actual es:\n" +
System.out.println("-------------------------\nLa cancion actual es:" +
cancionActual.toString() +
"\nElija una de las opciones posibles:\n" +
"\n-------------------------\nElija una de las opciones posibles:\n" +
opciones
);
String input = scanner.nextLine();
switch (input){
case "1":
String respMedia = orServer.startMedia(or.readL());
while(orCliente.isMediaPlayerActive()){
Thread.sleep(2000);
}
cancionActual = or.peekL();
break;
case "2":
or.readL();
if(or.peekL() != null) {
cancionActual = or.peekL();
}else{
System.out.println("Ya no hay mas canciones en la playlist.\n");
termina=true;
}
break;
case "3":
termina=true;
......@@ -68,13 +73,16 @@ public class PlayList {
}
} catch (java.rmi.RemoteException re) {
System.err.println("<Cliente: Excepción RMI: "+re);
re.printStackTrace();
} catch (Exception e) {
System.err.println("<Cliente: Excepcion: "+e);
e.printStackTrace();
}finally {
scanner.close();
System.exit(0); //Mirar esto bien, puede que no haga falta si
//se cierran los objetos rmi necesarios?¿ pero no estoy seguro de eso
}
}
}
package spotify.rmi.client.stream.unit;
import spotify.media.Media;
import spotify.rmi.client.SpotifyClientImpl;
import spotify.rmi.client.stream.SpotifyClientImpl;
import spotify.rmi.common.Spotify;
import spotify.rmi.common.SpotifyServer;
......
......@@ -2,7 +2,7 @@ package spotify.rmi.client.stream.unit;
import spotify.media.Media;
import spotify.rmi.common.*;
import spotify.rmi.client.SpotifyClientImpl;
import spotify.rmi.client.stream.SpotifyClientImpl;
import java.rmi.Naming;
......@@ -29,7 +29,7 @@ public class PlaySong {
}
String respMedia = orServer.startMedia(media);
System.out.println("[Respuesta: "+respMedia+"]");
} catch (java.rmi.RemoteException re) {
......
......@@ -22,7 +22,7 @@ public class ServerStream implements Runnable{
}
public void run(){
try {
ServerSocket servsock = new ServerSocket(20099);
ServerSocket servsock = new ServerSocket(Globals.server_port);
this.serverSocketPort = servsock.getLocalPort();
System.out.println("--Stream Waiting...");
Socket sock = servsock.accept();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment