Continuous Playing of Different Video Files in a VLC Playlist - c#

I am trying to play different video files continuously on VLC player on my Winform application.
The problem I face is between different playlist videos there is a 1-2 seconds of black screen.
How can I play all videos in my playlist smoothly without any waiting?
private void buttonLoad_Click(object sender, EventArgs e)
{
var uri = new Uri(#"C:\Users\Val\Downloads\000013.ts");
var converted = uri.AbsoluteUri;
var uri2 = new Uri(#"C:\Users\Val\Downloads\000210.ts");
var converted2 = uri2.AbsoluteUri;
axVLCPlugin21.playlist.add(converted);
axVLCPlugin21.playlist.add(converted2);
}
private void buttonStart_Click(object sender, EventArgs e)
{
axVLCPlugin21.MediaPlayerEndReached += new EventHandler(OnTimedEvent);
axVLCPlugin21.playlist.playItem(0);
}
private void OnTimedEvent(object sender, EventArgs e)
{
axVLCPlugin21.playlist.playItem(1);
}
this is a simplified version of what I am trying to do.
When the player reaches end of the first video file it starts the second on by eventhandler function.

The best way I know to play videos seamlessly is to avoid the timed event in your example:
private void buttonLoad_Click(object sender, EventArgs e)
{
var uri = new Uri(#"C:\Users\Val\Downloads\000013.ts");
var converted = uri.AbsoluteUri;
var uri2 = new Uri(#"C:\Users\Val\Downloads\000210.ts");
var converted2 = uri2.AbsoluteUri;
axVLCPlugin21.playlist.add(converted);
axVLCPlugin21.playlist.add(converted2);
}
private void buttonStart_Click(object sender, EventArgs e)
{
axVLCPlugin21.playlist.play();
}

Related

Issue with MediaElement and thread.sleep

I am making a selection change from a combobox. When that event occurs, I want to play one media file, pause 5 seconds and then play another media file. What is actually happening is that there is a 5 second pause. Then only the second media file plays (vb.mp4). What am I doing wrong here?
private void cmb_adGroupZoneOne_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.mediaElement.Source = new Uri("C:/fb.mp4");
this.mediaElement.LoadedBehavior = MediaState.Manual;
this.mediaElement.Play();
System.Threading.Thread.Sleep(5000);
this.mediaElement.Source = new Uri("C:/vb.mp4");
this.mediaElement.LoadedBehavior = MediaState.Manual;
this.mediaElement.Play();
}
<MediaElement Name="mediaElement" MediaEnded="mediaElement_MediaEnded" />
private void cmb_adGroupZoneOne_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.mediaElement.Source = new Uri("C:/fb.mp4");
this.mediaElement.LoadedBehavior = MediaState.Manual;
this.mediaElement.Play();
}
private void mediaElement_MediaEnded(object sender, RoutedEventArgs e)
{
System.Threading.Thread.Sleep(5000);
this.mediaElement.Source = new Uri("C:/vb.mp4");
this.mediaElement.LoadedBehavior = MediaState.Manual;
this.mediaElement.Play();
}

Voice recognition using System.Speech not working correctly

I have been trying to experiment with the system.speech feature I have seen various online videos and web articles teaching how to properly use it, but I can't get it to work somehow. I get no errors, the program compiles as it should but when I speak nothing happens, I have tried changing my language to en-UK and back to en-US but it did nothing. I am using VS17 and the code is as follows:
SpeechRecognitionEngine recEngine = new SpeechRecognitionEngine(new CultureInfo("en-US"));
public Form1()
{
InitializeComponent();
this.TransparencyKey = (BackColor);
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Convert.ToInt32(0.10), 300);
textBox1.Visible = false;
}
private void Form1_Load(object sender, EventArgs e)
{
Choices commands = new Choices();
commands.Add(new string[] { "hello" });
GrammarBuilder gr = new GrammarBuilder();
gr.Append(commands);
Grammar grammar = new Grammar(gr);
recEngine.LoadGrammarAsync(grammar);
recEngine.SetInputToDefaultAudioDevice();
recEngine.SpeechRecognized += RecEngine_SpeechRecognized;
}
private void RecEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
switch (e.Result.Text)
{
case "hello":
MessageBox.Show("Hello");
break;
}
}
private void label1_Click(object sender, EventArgs e)
{
}
private void pictureBox2_Click(object sender, EventArgs e)
{
recEngine.RecognizeAsyncStop();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
void button1_Click(object sender, EventArgs e)
{
recEngine.RecognizeAsync(RecognizeMode.Multiple);
}
}
Edit: I downloaded and tested the program with the same code below on 2 different computers and it works fine with all of them except this one. I tried to use the mic of both computers which recognized my speech. But none of them worked, so the problem lies within my PC after all, I might have to download some windows update with the speech feature or something like that. Where can I find it though?
Apparently running as an admin fixed the issue.
Somehow this thought never even reached my mind.

Make a buttom that saves my picture, in a folder that gets its name from a textbox

I am trying to make a program for the car retail firm I work at. When people deliver their cars, a guy has to take pictures of the damages with a Lenovo miix.
The program I've made so far is not smart enough.
It goes like, you write the numberplate in a box, then create a folder with the text from the box.
Then you start the camera, take a picture and save it, and manually have to find the folder and name the file.
Is there a way I can make it smarter with just 2 buttons, one to start the camera and another one to take the picture, and then it automatically saves it in a folder named as the numberplate, and files named 1,2,3,4 and so on.jpg ?
this is my code so far:
namespace Europcar_skade_camera
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private FilterInfoCollection webcam;
private VideoCaptureDevice cam;
private void Form1_Load(object sender, EventArgs e)
{
webcam = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach(FilterInfo VideoCaptureDevice in webcam)
{
comboBox1.Items.Add(VideoCaptureDevice.Name);
}
comboBox1.SelectedIndex = 1;
}
private void button1_Click(object sender, EventArgs e)
{
cam = new VideoCaptureDevice(webcam[comboBox1.SelectedIndex].MonikerString);
cam.NewFrame += new NewFrameEventHandler(Cam_NewFrame);
cam.Start();
}
private void Cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap bit = (Bitmap)eventArgs.Frame.Clone();
pictureBox1.Image = bit;
}
private void button3_Click(object sender, EventArgs e)
{
if (cam.IsRunning)
{
cam.Stop();
}
}
private void button2_Click(object sender, EventArgs e)
{
saveFileDialog1.InitialDirectory = #"C:\tmp\";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image.Save(saveFileDialog1.FileName);
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
{
}
private void nummerplade_TextChanged(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
Directory.CreateDirectory(#"c:\tmp\" + nummerplade.Text);
}
}
}
Something like this:
Instead of using a SaveFileDialog, you could just create the file path based on the number plate value like this:
var filePath = System.IO.Path.Combine(#"c:\tmp", nummerplade.Text, fileNumber + ".jpeg");
The fileNumber var is the number of files allready in the folder + 1.
var fileNumber = Directory.GetFiles(...).Length + 1
string numberPlate = "21323412";
string path = #"C:\tmp\";
Directory.CreateDirectory(path + numberPlate); //to create folder
string dirpath = path + numberPlate; //to get name of fodler we created
You also mentioned that you want incremental names, there are many ways of doing it, personally i'd prefer large hashed name of file like so:
//generate GUID and convert to string.
string filename = Guid.NewGuid().ToString();
//to save picturebox image in folder and use ImageFormat.Your desired format
pictureBox1.Image.Save(dirpath + #"\"+filename+".jpeg", ImageFormat.Jpeg);
But if you want to stick with incremental names:
// you get last name in the folder:
//it gets last filename in folder but with path
var lastFilePath = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First();
//we remove path from filename and convert it to int.
int lastIndex = Int32.Parse(Path.GetFileNameWithoutExtension(lastFilePath));
//then we increment it by 1
int newName = lastIndex + 1;
//and save it
pictureBox1.Image.Save(dirpath + #"\"+filename+".jpeg", ImageFormat.Jpeg); //to save picturebox image in folder
With GUID finally it should look something like this:
string numberPlate = "21323412";
string path = #"C:\tmp\";
private void button2_Click(object sender, EventArgs e)
{
Directory.CreateDirectory(path + numberPlate); //to create folder
string dirpath = path + numberPlate; //to get name of fodler we created
string filename = Guid.NewGuid().ToString();
pictureBox1.Image.Save(dirpath + #"\"+filename+".jpeg", ImageFormat.Jpeg); //to save picturebox image in folder
}

take a snapshot from wecam by using DShowNET library

how can i make a snapshot in my cod:
using DirectX.Capture;
using DShowNET;
private void Form1_Shown(object sender, EventArgs e)
{
DirectX.Capture.Capture capture = null;
Filters filters = null;
capture = new DirectX.Capture.Capture(filters.VideoInputDevices[deviceNo], filters.AudioInputDevices[0]);
capture.PreviewWindow = pictureBox1;
}
private void _Pause_Click(object sender, EventArgs e)
{
//??
}
i want to convert pictureBox1's video stream to a image by clicking on "Pause" button.
and then save pictureBox1's pic(*.jpg) to data base.

Windows Phone uploading images to azure blob service

I want to upload a photo from my phone to azure blob.
Im using this link
http://www.windowsazure.com/en-us/develop/mobile/tutorials/upload-images-to-storage-wp8/
there is no error or a exception, it just i cant see it and i know the binding is correct,
even when i open the link of the image, there is no photo found.
there is a question similar to this one here
Upload image to Azure blob storage from Windows Phone. Not creating
This is what I'm doing
PhotoChooserTask chooser;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Refresh();
base.OnNavigatedTo(e);
}
private void PhotoChooserBtn_Click(object sender, RoutedEventArgs e)
{
chooser = new PhotoChooserTask();
chooser.Completed += chooser_Completed;
chooser.Show();
}
Stream stream = null;
void chooser_Completed(object sender, PhotoResult e)
{
stream = e.ChosenPhoto;
BitmapImage sourceImg = new BitmapImage();
sourceImg.SetSource(stream);
ProfileImage.Source = sourceImg;
}
async private void SaveBtn_Click(object sender, RoutedEventArgs e)
{
Images images = new Images() { Username = "7elbeh" };
InsertImage(images);
}
private void RefreshBtn_Click(object sender, RoutedEventArgs e)
{
Refresh();
}
please help.
I have the same error, to solve i convert my Stream to array and use UploadFromByteArrayAsync
byte[] array = imageStream.ToArray();
await blobFromSASCredential.UploadFromByteArrayAsync(array, 0, array.Length);

Categories