103 lines
3.0 KiB
C#
103 lines
3.0 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
using System.Windows.Media;
|
|||
|
|
using System.Windows.Media.Imaging;
|
|||
|
|
namespace Nanji_Island
|
|||
|
|
{
|
|||
|
|
public partial class Form4 : Form
|
|||
|
|
{
|
|||
|
|
IntPtr libvlc_instance_;
|
|||
|
|
IntPtr libvlc_media_player_;
|
|||
|
|
|
|||
|
|
public Form4()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//初始化按钮
|
|||
|
|
private void button1_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
libvlc_instance_ = MediaPlayer.Create_Media_Instance();
|
|||
|
|
libvlc_media_player_ = MediaPlayer.Create_MediaPlayer(libvlc_instance_, panel1.Handle);
|
|||
|
|
}
|
|||
|
|
catch (Exception err)
|
|||
|
|
{
|
|||
|
|
Console.WriteLine(err.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//网络视频播放
|
|||
|
|
private void button3_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (textBox2.Text.Trim() != "")
|
|||
|
|
{
|
|||
|
|
MediaPlayer.NetWork_Media_Play(libvlc_instance_,libvlc_media_player_,textBox2.Text);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
System.Windows.Forms.MessageBox.Show("请输入网络地址");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//本地视频播放
|
|||
|
|
private void btn_local_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|||
|
|
ofd.Filter = "All Files(*.*)|*.*";
|
|||
|
|
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
textBoxLocation.Text = ofd.FileName;
|
|||
|
|
MediaPlayer.LocationPath_Media_Play(libvlc_instance_,libvlc_media_player_,ofd.FileName);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//录制
|
|||
|
|
private void button2_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (button_save.Text == "REC")
|
|||
|
|
{
|
|||
|
|
if (textBox1.Text.Trim() != "")
|
|||
|
|
{
|
|||
|
|
MediaPlayer.Save_MediaPlayer(libvlc_media_player_, textBox1.Text);
|
|||
|
|
button_save.Text = "RECing...";
|
|||
|
|
button_save.BackColor = System.Drawing.Color.Green;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//没有播放路径弹窗提示
|
|||
|
|
System.Windows.Forms.MessageBox.Show("请选择录像保存路径");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MediaPlayer.UnSave_MediaPlayer(libvlc_media_player_);
|
|||
|
|
button_save.Text = "REC";
|
|||
|
|
button_save.BackColor = System.Drawing.Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//选择保存路径
|
|||
|
|
private void button2_Click_1(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SaveFileDialog save = new SaveFileDialog();
|
|||
|
|
if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
textBox1.Text = save.FileName;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Form4_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|