@ -22,6 +22,7 @@ public class RadioPlayer implements Device {
LocalDateTime now = LocalDateTime . now ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
int hour = now . getHour ( ) ;
int hour = now . getHour ( ) ;
int Lautstaerke = 0 ;
int Lautstaerke = 0 ;
int savedVolume ;
String playedStation = "" ;
String playedStation = "" ;
public String getYouFMInfoByTime ( int x ) {
public String getYouFMInfoByTime ( int x ) {
@ -158,22 +159,50 @@ public class RadioPlayer implements Device {
@Override
@Override
public String chooseItem ( int itemNr ) {
public String chooseItem ( int itemNr ) {
return null ;
if ( regionPlaylist . contains ( playedStation ) ) {
if ( itemNr > regionPlaylist . size ( ) ) {
playedStation = regionPlaylist . get ( regionPlaylist . size ( ) - 1 ) ;
return ( "Radio is playing station: 0" + regionPlaylist . size ( ) + " " + this . playedStation + " from regional playlist" ) ;
} else if ( itemNr < 1 ) {
playedStation = regionPlaylist . get ( 0 ) ;
return ( "Radio is playing station: 01 " + this . playedStation + " from regional playlist" ) ;
} else {
playedStation = regionPlaylist . get ( itemNr - 1 ) ;
return ( "Radio is playing station: 0" + ( regionPlaylist . indexOf ( playedStation ) + 1 ) + " " + this . playedStation + " from regional playlist" ) ;
}
} else {
if ( itemNr > savedPlaylist . size ( ) ) {
playedStation = savedPlaylist . get ( savedPlaylist . size ( ) - 1 ) ;
return ( "Radio is playing station: 0" + savedPlaylist . size ( ) + " " + this . playedStation + " from saved playlist" ) ;
} else if ( itemNr < 1 ) {
playedStation = savedPlaylist . get ( 0 ) ;
return ( "Radio is playing station: 01 " + this . playedStation + " from saved playlist" ) ;
} else {
playedStation = savedPlaylist . get ( itemNr - 1 ) ;
return ( "Radio is playing station: 0" + ( savedPlaylist . indexOf ( playedStation ) + 1 ) + " " + this . playedStation + " from saved playlist" ) ;
}
}
}
}
@Override
@Override
public String [ ] getItemList ( ) {
public String [ ] getItemList ( ) {
return null ;
if ( regionPlaylist . contains ( playedStation ) )
return regionPlaylist . toArray ( new String [ 0 ] ) ;
else
return savedPlaylist . toArray ( new String [ 0 ] ) ;
}
}
@Override
@Override
public String mute ( ) {
public String mute ( ) {
return null ;
savedVolume = getVolume ( ) ;
setLautstaerke ( 0 ) ;
return "RadioPlayer is muted now" ;
}
}
@Override
@Override
public String unmute ( ) {
public String unmute ( ) {
return null ;
setLautstaerke ( savedVolume ) ;
return ( "RadioPlayer is unmuted Volume is set to " + getVolume ( ) ) ;
}
}
@ -218,7 +247,7 @@ public class RadioPlayer implements Device {
}
}
public String changeToSavedPlaylist ( ) {
public String changeToSavedPlaylist ( ) {
if ( regionPlaylist . contains ( playedStation ) ) {
if ( regionPlaylist . contains ( playedStation ) ) {
playedStation = savedPlaylist . get ( 0 ) ;
playedStation = savedPlaylist . get ( 0 ) ;
regionPlaylist . clear ( ) ;
regionPlaylist . clear ( ) ;
return "Playlist switched now playing station: 0" + ( savedPlaylist . indexOf ( playedStation ) + 1 ) + " " + this . playedStation + " from saved playlist" ;
return "Playlist switched now playing station: 0" + ( savedPlaylist . indexOf ( playedStation ) + 1 ) + " " + this . playedStation + " from saved playlist" ;
@ -228,16 +257,15 @@ public class RadioPlayer implements Device {
public String changeOrderInSavedPlaylist ( int nr ) {
public String changeOrderInSavedPlaylist ( int nr ) {
String station = playedStation ;
String station = playedStation ;
if ( ( nr - 1 ) > savedPlaylist . size ( ) ) {
if ( ( nr - 1 ) > savedPlaylist . size ( ) ) {
savedPlaylist . remove ( playedStation ) ;
savedPlaylist . remove ( playedStation ) ;
savedPlaylist . add ( savedPlaylist . size ( ) , station ) ;
return "Station " + playedStation + " is now on place 0" + ( savedPlaylist . size ( ) + 1 ) + "in saved playlist" ;
} else if ( nr < 0 ) {
savedPlaylist . add ( savedPlaylist . size ( ) , station ) ;
return "Station " + playedStation + " is now on place 0" + ( savedPlaylist . size ( ) + 1 ) + "in saved playlist" ;
} else if ( nr < 0 ) {
savedPlaylist . remove ( playedStation ) ;
savedPlaylist . remove ( playedStation ) ;
savedPlaylist . add ( 0 , station ) ;
return "Station " + playedStation + " is now on place 01 in saved playlist" ;
}
else {
savedPlaylist . add ( 0 , station ) ;
return "Station " + playedStation + " is now on place 01 in saved playlist" ;
} else {
savedPlaylist . remove ( playedStation ) ;
savedPlaylist . remove ( playedStation ) ;
savedPlaylist . add ( nr - 1 , station ) ;
savedPlaylist . add ( nr - 1 , station ) ;
return "Station " + playedStation + " is now on place 0" + nr + "in saved playlist" ;
return "Station " + playedStation + " is now on place 0" + nr + "in saved playlist" ;