本人想做一个支持弹幕的视频播放器,用GDI来实时画出弹幕内容。可是本人尝试画出的弹幕好像是被视频播放器给挡住了,看不见,这个怎么处理,请高手指点一下,谢谢!
弹幕内容是”本人是画出来的文字!”
弹幕内容是”本人是画出来的文字!”
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace dmshipin
{
public partial class Form1 : Form
{
int i = 1500;
public Form1()
{
InitializeComponent();
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @"d:\h1.mp4";
//axWindowsMediaPlayer1.uiMode = "none";
}
private void timer1_Tick(object sender, EventArgs e)
{
System.Drawing.Size size = this.Size;
System.Drawing.Point point = this.Location;
int left = this.Left;
int width = this.Width;
if (i < 10)
{
i = width - 10;
}
else {
i = i - 5;
}
label1.Location = new Point(i, 40);
label1.BackColor = Color.Transparent;
label2.Location = new Point(i+10, 80);
label3.Location = new Point(i-5, 120);
label4.Location = new Point(i+20, 160);
////画出的文字
Graphics g = this.CreateGraphics();
Font font = new Font("华为宋体", 20);
//Point一样,只是值是浮点类型
PointF point1 = new PointF(150, 150);
g.DrawString("本人是画出来的文字!", font, Brushes.Coral, point1);
}
}
}
解决方案
10
你需要拖个别的控件,将parent设定为axWindowsMediaPlayer1,将背景色设定为transparent
30
g是this create的。所以drawString当然也是在窗体背景上啊
试试用播放器那个控件creategraphics
试试用播放器那个控件creategraphics