patterns/facade/hometheater/streamingplayer.d

76 lines
1.5 KiB
D

module streamingplayer;
import amplifier;
import std.stdio : writeln;
import std.conv : to;
class StreamingPlayer
{
private string description;
private int currentChapter;
private Amplifier amplifier;
private string movie;
this(string description, Amplifier amplifier)
{
this.description = description;
this.amplifier = amplifier;
}
void on()
{
writeln(description ~ " on");
}
void off()
{
writeln(description ~ " off");
}
void play(string movie)
{
this.movie = movie;
currentChapter = 0;
writeln(description ~ " playing \"" ~ movie ~ "\"");
}
void play(int chapter)
{
if (movie is null)
{
writeln(description ~ " can't play chapter " ~ chapter.to!string ~ " on movie selected");
}
else
{
currentChapter = chapter;
writeln(description ~ " playing chapter " ~ currentChapter.to!string ~ " off \"" ~ movie ~ "\"");
}
}
void stop()
{
currentChapter = 0;
writeln(description ~ " stopped \"" ~ movie ~ "\"");
}
void pause()
{
writeln(description ~ " paused \"" ~ movie ~ "\"");
}
void setTwoChannelAudio()
{
writeln(description ~ " set two channel audio");
}
void setSurroundAudio()
{
writeln(description ~ " set surround audio");
}
override string toString() const
{
return description;
}
}