TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Roel Toca
NA
5
2.7k
How to autoplay next song/video in WMP in C# with mysql
Oct 15 2017 8:39 AM
How do I play the next song/video from the listBox automatically
the path is inside the listBox the problem is how do I get to play the song/video in it
Here is my code:
namespace
JustSingSystem
{
public
partial
class
Karaoke : Form
{
MySqlConnection connection =
new
MySqlConnection(
"datasource=localhost;port=3306;username=root;password=seven7"
);
MySqlCommand command;
MySqlDataReader mdr;
public
Karaoke()
{
InitializeComponent();
}
private
void
button8_Click(
object
sender, EventArgs e)
{
try
{
connection.Open();
string
selectQuery =
"SELECT * FROM justsing.songsinfo WHERE songnumber="
+
int
.Parse(textBox1.Text);
command =
new
MySqlCommand(selectQuery, connection);
mdr = command.ExecuteReader();
if
(mdr.Read())
{
textBox2.Text = mdr.GetString(
"song"
);
textBox3.Text = mdr.GetString(
"song"
);
}
else
{
textBox2.Text =
""
;
textBox1.Text =
""
;
MessageBox.Show(
"No Data For This Id"
);
}
connection.Close();
listBox1.Items.Add(
this
.textBox2.Text);
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private
void
button1_Click(
object
sender, EventArgs e)
{
SoundPlayer splayer =
new
SoundPlayer(@
"C:\Users\Tocz\Desktop\Macromedia\test.wav"
);
splayer.Play();
}
private
void
listBox1_SelectedIndexChanged(
object
sender, EventArgs e)
{
}
private
void
button13_Click(
object
sender, EventArgs e)
{
connection.Open();
string
selectQuery =
"SELECT * FROM justsing.songsinfo WHERE songnumber="
+
int
.Parse(textBox1.Text);
command =
new
MySqlCommand(selectQuery, connection);
mdr = command.ExecuteReader();
if
(mdr.Read())
{
textBox2.Text = mdr.GetString(
"song"
);
}
else
{
textBox2.Text =
""
;
textBox1.Text =
""
;
MessageBox.Show(
"No Data For This Id"
);
}
connection.Close();
axWindowsMediaPlayer1.URL =
""
+ textBox2.Text;
}
private
void
axWindowsMediaPlayer1_PlayStateChange(
object
sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
{
if
(axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
{
timer1.Interval = 100;
timer1.Enabled =
true
;
}
}
}
private
void
timer1_Tick(
object
sender, EventArgs e)
{
string
path = textBox2.Text;
if
(listBox1.SelectedIndex < path.Length - 1)
{
listBox1.SelectedIndex++;
timer1.Enabled =
false
;
axWindowsMediaPlayer1.Ctlcontrols.play();
}
else
{
listBox1.SelectedIndex = 0;
timer1.Enabled =
false
;
}
}
}
}
Reply
Answers (
0
)
Attributes implemented in class through another class
interface implementation with another interface