and how to start a media file from a certain position, for example, from 32 seconds? Did you click on any track in the list and it starts at 32 seconds?
This code uses NAudio to read an MP3 file and play it starting from the specified time in seconds. Make sure to install the NAudio package via NuGet if you haven't already. using NAudio.Wave; class Program { static void Main(string[] args) { string filePath = "your_music_file_path.mp3"; double startTimeInSeconds = 30; // Start playing from 30 seconds using (var reader = new Mp3FileReader(filePath)) { using (var waveOut = new WaveOutEvent()) { waveOut.Init(reader); waveOut.PlaybackStopped += (sender, eventArgs) => { // Handle playback stopped event if needed }; reader.CurrentTime = TimeSpan.FromSeconds(startTimeInSeconds); waveOut.Play(); // Keep the program running until the music finishes while (waveOut.PlaybackState == PlaybackState.Playing) { System.Threading.Thread.Sleep(100); } } } } }
There is a Assembly called (System.IO.Ports ) through you may achieve this so..Here is a link hope it's help. Link-docs.microsoft.com/en-us/dotnet/api/system.io.ports.serialport?view=dotnet-plat-ext-3.1
@@edsonferraz1 if you are looking for USB Functions then you can check this Link-docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/developing-windows-applications-that-communicate-with-a-usb-device
Hello, I was able to auto-switch songs, there is no problem when I add several songs to the list at once and the song auto-skips (I was able to encode it). But when it's time for the song I added later, I get an "IndexOutOfRangeException" error. How can I fix this? This is where I got the error player.URL = path[Track_List.SelectedIndex];
Hi Rohit, Great video! How would I be able to save the state of the media player, so the 5 songs I have added, when I next open it they are there? Thanks
Its very easy Dainel you can simply add, update or delete store path using sql or any other database.....may b in the future there will b a video for this....
@@gauravmane9287Make sure you have named label properly & refer back to the tutorial and see where you are doing mistake ..this is how you will learn...
HELP ME PLEASE!! 'System.Array' does not contain a definition for 'Lenght' and no extension method 'Lenght' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)
You can play the next item by adding 1 to the selected Index and checking if the index is still within bounds Store the new index in a variable that will keep the new index until the item has been played or change the Selected Index directly, this will change the Selected Item and move the selection in the ListBox private int currentSongIndex = -1; void Player_MediaEnded(object sender, EventArgs e) { if(currentSongIndex == -1) { currentSongIndex = listBox.SelectedIndex; } currentSongIndex++; if(currentSongIndex < listBox.Items.Count) { player.Play(listBox.Items[currentSongIndex]); } else { // last song in listbox has been played } }
(System.IndexOutOfRangeException: 'Index was outside the bounds of the array.') I'm getting this error on line (player.URL = paths[lstTrack.SelectedIndex];)
Rohit Programming Zone __________________ To download TagLib, you can follow these steps: Go to the TagLib GitHub page at github.com/taglib/taglib. Click on the green "Code" button and select "Download ZIP" to download the latest version of TagLib as a ZIP file. Extract the contents of the ZIP file to a location of your choice. Alternatively, you can use Git to clone the TagLib repository to your local machine. Here are the steps to do that: Install Git on your system, if it is not already installed. Open a terminal or command prompt and navigate to the directory where you want to clone the TagLib repository. Type the following command to clone the TagLib repository: git clone github.com/taglib/taglib.git Wait for Git to finish cloning the repository to your local machine. After you have downloaded or cloned TagLib, you can follow the instructions in the README file to build and install the library on your system.
Guys! Give like, make a comment and share! This person need our help to make him popular because he made a lot of good work! Keep going
You are grate man, very nice and helpful video....😘😘😘😘❤️❤️❤️❤️❤️❤️
You are a champion of the people! Simply the best tutorial for making a media player on UA-cam. Great frickin job man! Thank you so much!
Thank you...❤️❤️
Thanks anyway your video is so helpful
Nice tutorial, But I am wondering if can run .h264 file. Which is the file of CCTV.
you can add this
lbl_msg.Text = "Playing: " + track_listed.SelectedItem.ToString();
this is for showing text, which music is playing right now
Thank you very much my teacher
Rohit, can you make textbox and button search title video in this tutorial next , please 🙏 ... ???
Hi Rohit, super video! But progress bar is a downloading icon it's normal bar how to give a bar so please tell me,and thank you with coding guidness.
Check my progressbar tutorial ...
Ok
A great tutorial. Thank You !
Супер 👍
Hi Rohit again one doubt how to embeding ( online searching)a video in media player in c# .
and how to start a media file from a certain position, for example, from 32 seconds? Did you click on any track in the list and it starts at 32 seconds?
This code uses NAudio to read an MP3 file and play it starting from the specified time in seconds. Make sure to install the NAudio package via NuGet if you haven't already.
using NAudio.Wave;
class Program
{
static void Main(string[] args)
{
string filePath = "your_music_file_path.mp3";
double startTimeInSeconds = 30; // Start playing from 30 seconds
using (var reader = new Mp3FileReader(filePath))
{
using (var waveOut = new WaveOutEvent())
{
waveOut.Init(reader);
waveOut.PlaybackStopped += (sender, eventArgs) =>
{
// Handle playback stopped event if needed
};
reader.CurrentTime = TimeSpan.FromSeconds(startTimeInSeconds);
waveOut.Play();
// Keep the program running until the music finishes
while (waveOut.PlaybackState == PlaybackState.Playing)
{
System.Threading.Thread.Sleep(100);
}
}
}
}
}
@@rohitprogrammer And how can you do it for video?
OK very good vídeo, congratulation. A question please; Is possible open a device input in the USB or HDMI ports?
There is a Assembly called (System.IO.Ports ) through you may achieve this so..Here is a link hope it's help.
Link-docs.microsoft.com/en-us/dotnet/api/system.io.ports.serialport?view=dotnet-plat-ext-3.1
@@rohitprogrammer Ok thanks a lot
@@edsonferraz1 if you are looking for USB Functions then you can check this Link-docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/developing-windows-applications-that-communicate-with-a-usb-device
@@rohitprogrammer Thanks for help
Hello, I was able to auto-switch songs, there is no problem when I add several songs to the list at once and the song auto-skips (I was able to encode it).
But when it's time for the song I added later, I get an "IndexOutOfRangeException" error. How can I fix this?
This is where I got the error player.URL = path[Track_List.SelectedIndex];
Hey sir! did you get the solution
I have a cuestion, how add botton for remove items of list??
Is your source code link has correct? It show only strange advertisement...
Hi Rohit, Great video! How would I be able to save the state of the media player, so the 5 songs I have added, when I next open it they are there? Thanks
Also would you have ideas on how to create a playlist within the media player?
Its very easy Dainel you can simply add, update or delete store path using sql or any other database.....may b in the future there will b a video for this....
and when I right click on a media file how should it bring the player icon on the "open with" menu?
very nice !!! how would i be able to delete song from the list and also from the actual location of the song ???
There is a video name called Add Save Delete Load Media Playlist files in C# Visual Studio
...go through it ..hope it help... :)
Showing error for lbl_msg.Text ="playing";
@@gauravmane9287Make sure you have
named label properly & refer back to the tutorial and see where you are doing mistake ..this is how you will learn...
Sir make the coding of progreesbar ( seekbar ) media player in c# ( means forword the video and backwword the video pls ) make
Same question
HELP ME PLEASE!!
'System.Array' does not contain a definition for 'Lenght' and no extension method 'Lenght' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)
you spelt Length wrong
hello, the volume percentage limit stays 10. Any idea what may i have done wrong? i did try a lot to find a solution.
i found it. i forgot to change the max value from the .designer when you single click the trackbar.
And how can I make the list box show the name of the file organized, for example, to see the name of the song, artist and duration
U can check this one
ua-cam.com/video/tnOB6Bn5F6A/v-deo.html
@@rohitprogrammer i want to make the same but I’m trying make the information of name, artist, duration organized in the listbox appear
Can you make it with a search bar?
Go through this video..!
ua-cam.com/video/tnOB6Bn5F6A/v-deo.html
@@rohitprogrammer thank you
How can I make it keep playing song by song?
How can I play all files at list box automacally?
You can play the next item by adding 1 to the selected Index and checking if the index is still within bounds
Store the new index in a variable that will keep the new index until the item has been played or change the Selected Index directly, this will change the Selected Item and move the selection in the ListBox
private int currentSongIndex = -1;
void Player_MediaEnded(object sender, EventArgs e)
{
if(currentSongIndex == -1)
{
currentSongIndex = listBox.SelectedIndex;
}
currentSongIndex++;
if(currentSongIndex < listBox.Items.Count)
{
player.Play(listBox.Items[currentSongIndex]);
}
else
{
// last song in listbox has been played
}
}
Why does my error list say Cannot implicitly convert type 'string' to 'string[]'?
Nevermind I found out.
what about if we want to delete
items from the list
Check the video called Add Save Delete Load Media Playlist files in C# Visual Studio
..hope it help... :)
how to drag and drop a file onto the player ?
(System.IndexOutOfRangeException: 'Index was outside the bounds of the array.') I'm getting this error on line
(player.URL = paths[lstTrack.SelectedIndex];)
trackbar1.Value has to be less than 10
how to make multiplex button for karaoke function
No Source code file in the link u provided...
How can I download tag lib
Rohit Programming Zone
__________________
To download TagLib, you can follow these steps:
Go to the TagLib GitHub page at github.com/taglib/taglib.
Click on the green "Code" button and select "Download ZIP" to download the latest version of TagLib as a ZIP file.
Extract the contents of the ZIP file to a location of your choice.
Alternatively, you can use Git to clone the TagLib repository to your local machine. Here are the steps to do that:
Install Git on your system, if it is not already installed.
Open a terminal or command prompt and navigate to the directory where you want to clone the TagLib repository.
Type the following command to clone the TagLib repository: git clone github.com/taglib/taglib.git
Wait for Git to finish cloning the repository to your local machine.
After you have downloaded or cloned TagLib, you can follow the instructions in the README file to build and install the library on your system.