منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : كيفية عمل History في ميديا بلير
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
اريد عمل History يعمل في ميديا بلير ؟
هذا كان استخدم كود : AxWindowsMediaPlayer1.URL = "..."
حيث ان عندي ادوات :

TreeView1 : يكون فيها قنوات , واريد اي قناة تعمل في ميدابلير تسجل في ListBox1
ممكن مساعده
السلام عليكم ورحمة الله وبركاته

هذه فكرة عامة لعمل ذلك :

كود :
Public Class Form1


    Dim historyPath As String = Application.StartupPath & "\history.txt"


    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        Dim ofd As New OpenFileDialog
        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
            Me.AxWindowsMediaPlayer1.URL = ofd.FileName
            Me.AxWindowsMediaPlayer1.Ctlcontrols.play()
            Add2History(ofd.FileName) ' إضافة الملف المفتوح للهيستوري
            LoadHistroy()
        End If
    End Sub


    Private Sub Add2History(ByVal fname As String) ' دالة إضافة ملف للهيستوري
        Try
            If IO.File.Exists(historyPath) = False Then
                IO.File.CreateText(historyPath).Close()  ' إذا لم يُعثر علي الملف سيتم إنشاءه ثم إغلاقه
            End If
            My.Computer.FileSystem.WriteAllText(historyPath, fname & vbCrLf, True)
        Catch ex As Exception
            MsgBox(ex.Message, 48, "Add2History")
        End Try
    End Sub


    Private Sub LoadHistroy() ' دالة تحميل ملفات الهيستوري وإضافتها لأداة الليست بوكس
        Try
            If IO.File.Exists(historyPath) = False Then
                IO.File.CreateText(historyPath).Close()  ' إذا لم يُعثر علي الملف سيتم إنشاءه ثم إغلاقه
            End If
            Dim files() As String = IO.File.ReadAllLines(historyPath) 'قراءة جميع الملفات المحفوظة في ملف الهيستوري
            If files.Length > 0 Then '
                Me.ListBox1.Items.Clear()
                For Each itm As String In files
                    If itm <> "" Then
                        Me.ListBox1.Items.Add(itm) ' إضافة الملفات لأداة الليست بوكس
                    End If
                Next
            End If
        Catch ex As Exception
            MsgBox(ex.Message, 48, "LoadHistroy")
        End Try
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadHistroy() ' تحميل الهيستوري عند فتح النموذج
    End Sub


    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Try ' لتشغيل الملفات الموجودة في الهيستوري
            If Me.ListBox1.Items.Count > 0 Then
                If Me.ListBox1.SelectedItems IsNot Nothing Then
                    Me.AxWindowsMediaPlayer1.URL = Me.ListBox1.SelectedItem.ToString
                    Me.AxWindowsMediaPlayer1.Ctlcontrols.play()
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.Message, 48, "Play from Histroy")
        End Try
    End Sub
End Class

****
***
**
*
يااخي ما يعمل الكود معي
إذا كنت بتعمل علي ويندوز 7 اعطي برنامج صلاحيات مدير النظام