Video abspielen
-
Hi,
ich schreibe gerade ein kleines Tool für meine Masterarbeit.
Leider bekomme ich es nicht hin ein Video in einem Fenster abzuspielen.Könnt ihr mir irgendwie helfen ?
Tipps oder sonstiges ??
Danke
-
Du kannst ja c# schnell nach c++ umschreiben:
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 Microsoft.DirectX.AudioVideoPlayback; namespace VideoTest { public partial class Form1 : Form { Video myVid = new Video("K:\\test.avi"); public Form1() { InitializeComponent(); myVid.Owner = panel1; } private void button1_Click(object sender, EventArgs e) { myVid.Play(); } } }
-
hi,
einfach den WM Player einbinden und den Link vom Video übergeben
void InitializeComponent(void) { System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); this->axWindowsMediaPlayer1 = (gcnew AxWMPLib::AxWindowsMediaPlayer()); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->axWindowsMediaPlayer1))->BeginInit(); this->SuspendLayout(); // // axWindowsMediaPlayer1 // this->axWindowsMediaPlayer1->Enabled = true; this->axWindowsMediaPlayer1->Location = System::Drawing::Point(12, 12); this->axWindowsMediaPlayer1->Name = L"axWindowsMediaPlayer1"; this->axWindowsMediaPlayer1->OcxState = (cli::safe_cast<System::Windows::Forms::AxHost::State^ >(resources->GetObject(L"axWindowsMediaPlayer1.OcxState"))); this->axWindowsMediaPlayer1->Size = System::Drawing::Size(260, 238); this->axWindowsMediaPlayer1->TabIndex = 0; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(284, 262); this->Controls->Add(this->axWindowsMediaPlayer1); this->Name = L"Form1"; this->Text = L"Form1"; (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->axWindowsMediaPlayer1))->EndInit(); this->ResumeLayout(false); }
-
HI,
ich danke euch beiden.
bei der c lösen , diese habe ich mal in c eingegeben jedoch hatte ich 2 Fehler
C:\Users\Caosmen\Documents\Visual Studio 2008\Projects\VideoTest\VideoTest\Class1.cs(14,34): Fehler CS0246: Der Typ- oder Namespacename "Form" konnte nicht gefunden werden. (Fehlt eine Using-Direktive oder ein Assemblyverweis?)
C:\Users\Caosmen\Documents\Visual Studio 2008\Projects\VideoTest\VideoTest\Class1.cs(17,9): Fehler CS0246: Der Typ- oder Namespacename "Video" konnte nicht gefunden werden. (Fehlt eine Using-Direktive oder ein Assemblyverweis?)und die c++ lösung weiss ich leider nicht ganz einzuordnen.
tut mir leid wenn ich nun etwas blöd frage, aber wo könnte ich soetwas erstmal global nachlesen ?
Mir fehlen in der Sache anscheinend etwas die Grundlagen.
Danke euch
Ich habe bisher auch diese Lösung gefunden
namespace Video_Test { using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX.AudioVideoPlayback; /// <summary> /// Description of MainForm. /// </summary> public class MainForm : Form { OpenFileDialog openFileDialog; Video DXvideo = null; Panel VideoPanel; #region Windows Forms Designer generated code /// <summary> /// This method is required for Windows Forms designer support. /// Do not change the method contents inside the source code editor. The Forms designer might /// not be able to load this method if it was changed manually. /// </summary> void InitializeComponent() { this.openFileDialog = new OpenFileDialog(); // // openFileDialog // this.openFileDialog.Filter = "Video Dateien (*.avi)|*.avi|Alle Dateien (*.*)|*.*"; this.openFileDialog.Title = "Video auswählen"; // // MainForm // this.AutoScaleBaseSize = new Size( 5, 13 ); this.ClientSize = new Size( 320, 240 ); this.Name = "MainForm"; this.Text = "Dx9 Video Player"; } #endregion void CreatePanel() { if ( VideoPanel != null ) this.Controls.Remove( this.VideoPanel ); VideoPanel = null; VideoPanel = new Panel(); this.VideoPanel.Dock = DockStyle.Fill; this.VideoPanel.Location = new Point( 0, 0 ); this.VideoPanel.Name = "VideoPanel"; this.VideoPanel.Size = new Size( 320, 240 ); this.VideoPanel.TabIndex = 1; this.VideoPanel.MouseDown += new MouseEventHandler( this.panel1_MouseDown ); this.Controls.Add( this.VideoPanel ); } public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); CreatePanel(); } [STAThread] public static void Main( string[] args ) { Application.Run( new MainForm() ); } void panel1_MouseDown( object sender, MouseEventArgs e ) { if ( e.Button == MouseButtons.Left ) { if ( DXvideo == null || DXvideo != null && !DXvideo.Playing ) OpenVideo(); } else if ( e.Button == MouseButtons.Right ) { if ( DXvideo != null && DXvideo.Playing ) DXvideo.Stop(); OpenVideo(); } } void OpenVideo() { if ( openFileDialog.ShowDialog() == DialogResult.OK ) { try { if ( DXvideo == null ) DXvideo = new Video( openFileDialog.FileName, false ); else DXvideo.Open( openFileDialog.FileName ); DXvideo.Owner = VideoPanel; DXvideo.Ending += new EventHandler( video_Ending ); DXvideo.Play(); } catch ( Exception ex ) { MessageBox.Show( ex.ToString(), "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } } void video_Ending( object sender, EventArgs e ) { /* //Norberts Test DXvideo.Audio.Dispose(); // muss zuerst Disposed werden. DXvideo.Dispose(); // verursacht immer noch eine NullReferenceException DXvideo = null; CreatePanel(); */ OpenVideo(); } } }
leider auch dort 2 fehler..
irgendwas muss ich wohl noch falsch machen.
-
Hi,
kann keiner helfen ??
danke euch
-
sollte vll hilfreich sein
mfg
-
danke dir nun habe ich den mediaplayer drin klappt nun alles so wie es soll