X

الشرح الوافي لإقتباس وصناعة برنامج Damas Media Player

Programming Languages

 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Abufahmi
    Thread Author
    مشرف البرمجة والهندسة العكسية
    • Sep 2018 
    • 241 
    • 384 
    • 328 





    اللهم لا علم لنا الا ما علمتنا انك انت العليم الحكيم
    سلام الله عليكم




    أقدم لكم شرحا ثقيلا وموضوع طويل نوعا ما لصناعة برنامج شبيه
    ببرنامج Windows Media Player

    الشرح سيكون بالتفصيل ووافي لكل مراحل تصميم البرنامج ووضع
    الأكواد وبالتفصيل الممل وذلك استجابة لمن طلب مني شرح البرنامج
    بهذا الموضوع :
    مني العمل ومنكم التقييم (Damas Media Player)



    ليكون الناتج مثل هذا البرنامج





    والآن علي بركة نبدأ بالتحدث عن مراحل العمل :
    تصميم واجهة العمل كاملة وهي تتجزأ بما يلي :

    1- مرحلة ادخال ملفات ميديا بلير بالموضوع
    2- الفورم الرئيسي مع ربط الأكواد : abufahmiPlayer
    3- الفورم الفرعي مع ربط الأكواد : PlayList


    وعلي بركة الله نبدأ
    افتح مشروع جديد









    الآن قم بتسوية خصائص الفورم الرئيسي والذي أطلقت عليه abufahmiplayer



















    1- مرحلة ادخال ملفات ميديا بلير بالموضوع

    حتي أيسر عليكم عناء البحث ستجدون بالمرفقات ملفات dll
    الخاصة التي نريد اضافتها للموضوع




    دبل كلك علي المشروع للذهاب للخصائص







    إخواني الأعزاء طريقة إضافة أداة التصميم حيرتني كثيرا فهي مختلفة عن أدوات
    مثل WindowsMediaPlayer - vlcplug -realplug

    ولم استطع نقلها سوي بنسخها من المشروع المقتبس ولصقها بمشروعي الجديد








    2- الفورم الرئيسي مع ربط الأكواد : abufahmiPlayer

    نقوم الآن بإضافة جميع الأدوات اللازمة لمشروعنا






























    عرف المتغيرات هذه بداية الفورم :



    Code:
    Inherits System.Windows.Forms.Form
    Dim bool As Boolean = False
    Dim isMax As Boolean = False
    Dim isSizable As Boolean = True
    Dim isMute As Boolean = False
    Private myFormDragging As Boolean = False
    Private myPointClicked As Point
    Public isPause As Boolean = False

    في حدث علامة x :

    Code:
    Me.Close()
    في حدث - :
    Code:
    Me.WindowState = FormWindowState.Minimized
    في حدث + :
    [PHP
    Me.AxMediaPlayer1.fullScreen = True
    ][/CODE]


    في حدث openfile :

    Code:
    OpenFileDialog1.ShowDialog()
    If Not OpenFileDialog1.FileName = "" Then
    AxMediaPlayer1.settings.autoStart = True
    Timer1.Enabled = True
    AxMediaPlayer1.URL = OpenFileDialog1.FileName
    PictureBox1.Hide()
    PlayList.ListBox1.Items.Add(Me.AxMediaPlayer1.currentMedia.name)
    PlayList.urlArray(PlayList.count) = OpenFileDialog1.FileName
    PlayList.mediaArray(PlayList.count) = AxMediaPlayer1.currentMedia.name
    PlayList.count = PlayList.count + 1
    Label1.Text = Me.AxMediaPlayer1.currentMedia.name
    playButton.Enabled = True
    isPause = True
    Me.playButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_PAUSE1
    preButton.Enabled = True
    nextButton.Enabled = True
    Else
    playButton.Enabled = False
    End If
    وأخيرا بحدث about (هذا إضافي) :
    Code:
    about.Show()






    بحدث الصور من الشمال لليمين :
    التشغيل :


    Code:
    If Me.AxMediaPlayer1.URL = "" Then
    OpenFileDialog1.ShowDialog()
    If Not OpenFileDialog1.FileName = "" Then
    Timer1.Enabled = True
    AxMediaPlayer1.URL = OpenFileDialog1.FileName
    PictureBox1.Hide()
    Me.AxMediaPlayer1.mediaCollection.add(OpenFileDialog1.FileName)
    PlayList.ListBox1.Items.Add(Me.AxMediaPlayer1.currentMedia.name)
    Label1.Text = Me.AxMediaPlayer1.currentMedia.name
    playButton.Enabled = True
    preButton.Enabled = True
    nextButton.Enabled = True
    Else
    playButton.Enabled = False
    End If
    Else
    Me.TrackBar1.Enabled = True
    End If
    If isPause = False Then
    soundButton.Enabled = True
    Timer1.Enabled = True
    Me.playButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_PAUSE1
    AxMediaPlayer1.Ctlcontrols.play()
    PictureBox1.Hide()
    If Me.AxMediaPlayer1.currentMedia.name <> "" Then
    Label1.Text = Me.AxMediaPlayer1.currentMedia.name
    End If
    isPause = True
    stopButton.Enabled = True
    PictureBox4.Enabled = True
    Else
    isPause = False
    Me.playButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_PLAY1
    AxMediaPlayer1.Ctlcontrols.pause()
    Me.Timer1.Enabled = False
    PictureBox4.Enabled = True
    End If
    حدث الإيقاف :
    Code:
    isPause = False
    stopButton.Enabled = False
    Me.playButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_PLAY1
    AxMediaPlayer1.Ctlcontrols.stop()
    PictureBox1.Show()
    AxMediaPlayer1.Ctlcontrols.currentPosition = 0
    soundButton.Enabled = True
    playButton.Enabled = True
    حدث التسريع للخلف :
    Code:
    Me.AxMediaPlayer1.Ctlcontrols.fastReverse()

    حدث التسريع للأمام :

    Code:
    Me.AxMediaPlayer1.Ctlcontrols.fastForward()
    حدث السماعة :
    Code:
    If isMute = False Then
    Me.soundButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_MUTE_OFF1
    Me.AxMediaPlayer1.settings.mute = True
    Me.ToolTip1.SetToolTip(Me.soundButton, "Mute")
    Me.TrackBar2.Enabled = False
    isMute = True
    Else
    Me.soundButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_MUTE_ON1
    Me.AxMediaPlayer1.settings.mute = False
    Me.ToolTip1.SetToolTip(Me.soundButton, "Volume")
    Me.TrackBar2.Enabled = True
    isMute = False
    End If
    حدث إضافة ملف :
    Code:
    OpenFileDialog1.FileName = ""
    Me.PictureBox5.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.btn_open3
    OpenFileDialog1.ShowDialog()
    If Not OpenFileDialog1.FileName = "" Then
    Timer1.Enabled = True
    AxMediaPlayer1.URL = OpenFileDialog1.FileName
    PictureBox1.Hide()
    Me.AxMediaPlayer1.mediaCollection.add(OpenFileDialog1.FileName)
    PlayList.ListBox1.Items.Add(Me.AxMediaPlayer1.currentMedia.name)
    PlayList.urlArray(PlayList.count) = OpenFileDialog1.FileName
    PlayList.mediaArray(PlayList.count) = AxMediaPlayer1.currentMedia.name
    PlayList.count = PlayList.count + 1
    Label1.Text = Me.AxMediaPlayer1.currentMedia.name
    playButton.Enabled = True
    isPause = True
    Me.playButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_PAUSE1
    preButton.Enabled = True
    nextButton.Enabled = True
    Else
    playButton.Enabled = False
    End If
    حدث البلي ليست :
    Code:
    If bool = False Then
    PlayList.Show()
    Me.ToolTip1.SetToolTip(Me.playListButton, "Hide Playlist")
    bool = True
    Else
    PlayList.Hide()
    Me.ToolTip1.SetToolTip(Me.playListButton, "Show Playlist")
    bool = False
    End If
    حدث trackbar1 :
    Code:
    Try
    If Me.AxMediaPlayer1.currentMedia.duration <> 0 Then
    Dim duration As Double = Me.TrackBar1.Value / Me.TrackBar1.Maximum
    Me.AxMediaPlayer1.Ctlcontrols.currentPosition = Me.AxMediaPlayer1.currentMedia.duration * duration
    Else : Me.TrackBar1.Value = 0
    End If
    Catch ex As Exception
    End Try
    حدث trackbar2 :
    Code:
    Me.AxMediaPlayer1.settings.volume = TrackBar2.Value
    بحدث timer1 :
    Code:
    Try
    ' Set PlayList
    Me.AxMediaPlayer1.currentPlaylist.setItemInfo(Me.AxMediaPlayer1.currentMedia.name, Me.AxMediaPlayer1.currentMedia.durationString)
    Me.TrackBar1.Value = Convert.ToInt32((AxMediaPlayer1.Ctlcontrols.currentPosition / AxMediaPlayer1.currentMedia.duration) * 100)
    ' Marquee
    If (Me.Label1.Text.Length > 40) Then
    Me.Label1.Text = Mid(Me.Label1.Text, 2, Me.Label1.Text.Length - 1) + Mid(Me.Label1.Text, 1, 1)
    Else
    Me.Label1.Text += " "
    End If
    If Me.AxMediaPlayer1.Ctlcontrols.currentPositionString.Equals(Me.AxMediaPlayer1.currentMedia.durationString) Then
    ' Disable the Pause and the Stop buttons.
    isPause = False
    stopButton.Enabled = False
    ' Stop playing the audio file, and then reset the next play position to the beginning.
    Me.stopButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_STOP1
    Me.playButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_PLAY1
    AxMediaPlayer1.Ctlcontrols.stop()
    '
    PictureBox1.Show()
    AxMediaPlayer1.Ctlcontrols.currentPosition = 0
    ' Enable the Load and the Play buttons.
    PictureBox5.Enabled = True
    playButton.Enabled = True
    End If
    Catch ex As Exception
    Debug.WriteLine(ex.Message)
    Debug.WriteLine(ex.StackTrace)
    End Try
    وأخيرا بحدث form load :
    Code:
    Me.TrackBar2.Value = TrackBar2.Maximum
    Me.AxMediaPlayer1.settings.autoStart = True












    3- الفورم الفرعي مع ربط الأكواد : PlayList

    playlist نذهب للفورم الجديد الذي أنشأناه
    ثم دبل كلك لظهور فورم التصميم





    نضيف هذه الأدوات













    استدعي هذه الدوال :


    Code:
    Imports System
    Imports System.Drawing
    Imports System.Windows.Forms

    عرف المتغيرات هذه ببداية الفورم :

    Code:
    Inherits System.Windows.Forms.Form
    Dim isSizable As Boolean = False
    Dim isMax As Boolean = False
    Public urlArray(30) As String
    Public mediaArray(30) As String
    Public count As Integer = 0
    Private myFormDragging As Boolean = False
    Private myPointClicked As Point



    بحدث x :

    Code:
    Me.Close()
    abufahmiPlayer.Show()
    بحدث - :
    Code:
    Me.WindowState = FormWindowState.Minimized




    بحدث add:


    Code:
    OpenFileDialog1.FileName = ""
    OpenFileDialog1.ShowDialog()
    If Not OpenFileDialog1.FileName = "" Then
    abufahmiPlayer.AxMediaPlayer1.settings.autoStart = True
    abufahmiPlayer.Timer1.Enabled = True
    abufahmiPlayer.AxMediaPlayer1.URL = OpenFileDialog1.FileName
    abufahmiPlayer.PictureBox1.Hide()
    abufahmiPlayer.AxMediaPlayer1.mediaCollection.add(abufahmiPlayer.AxMediaPlayer1.URL)
    ListBox1.Items.Add(abufahmiPlayer.AxMediaPlayer1.currentMedia.name)
    urlArray(count) = OpenFileDialog1.FileName
    mediaArray(count) = abufahmiPlayer.AxMediaPlayer1.currentMedia.name
    count = count + 1
    abufahmiPlayer.Label1.Text = abufahmiPlayer.AxMediaPlayer1.currentMedia.name
    abufahmiPlayer.playButton.Enabled = True
    abufahmiPlayer.isPause = True
    abufahmiPlayer.playButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_PAUSE1
    abufahmiPlayer.PictureBox4.Enabled = False
    abufahmiPlayer.preButton.Enabled = True
    abufahmiPlayer.nextButton.Enabled = True
    Else
    abufahmiPlayer.playButton.Enabled = False
    End If
    بحدث del :
    Code:
    Dim i As Integer
    For i = 0 To count - 1 Step 1
    If ListBox1.SelectedItem = mediaArray(i) Then
    If Not ListBox1.SelectedIndex - 1 = -1 Then
    urlArray(i) = urlArray(i - 1)
    mediaArray(i) = mediaArray(i - 1)
    abufahmiPlayer.Label1.Text = ListBox1.Items.Item(ListBox1.SelectedIndex - 1)
    abufahmiPlayer.AxMediaPlayer1.URL = urlArray(i)
    ListBox1.Items.Remove(ListBox1.SelectedItem)
    ElseIf ListBox1.Items.Count = 1 Then
    abufahmiPlayer.Label1.Text = "Ready"
    abufahmiPlayer.AxMediaPlayer1.URL = ""
    ListBox1.Items.Remove(ListBox1.SelectedItem)
    ElseIf ListBox1.Items.Item(ListBox1.SelectedIndex + 1) <> "" Then
    abufahmiPlayer.Label1.Text = ListBox1.Items.Item(ListBox1.SelectedIndex + 1)
    urlArray(i) = urlArray(i + 1)
    mediaArray(i) = mediaArray(i + 1)
    abufahmiPlayer.AxMediaPlayer1.URL = urlArray(i)
    ListBox1.Items.Remove(ListBox1.SelectedItem)
    End If
    End If
    Next
    abufahmiPlayer.isPause = False
    abufahmiPlayer.stopButton.Enabled = False
    abufahmiPlayer.playButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_PLAY1
    abufahmiPlayer.AxMediaPlayer1.Ctlcontrols.stop()
    abufahmiPlayer.PictureBox1.Show()
    abufahmiPlayer.AxMediaPlayer1.Ctlcontrols.currentPosition = 0
    abufahmiPlayer.PictureBox5.Enabled = True
    abufahmiPlayer.playButton.Enabled = True
    abufahmiPlayer.PictureBox5.Enabled = False
    ListBox1.Items.Remove(ListBox1.SelectedItem)
    وبحدث clear all :
    Code:
    If ListBox1.Items.Count <> 0 Then
    ListBox1.Items.Clear()
    abufahmiPlayer.AxMediaPlayer1.Ctlcontrols.stop()
    abufahmiPlayer.AxMediaPlayer1.URL = ""
    abufahmiPlayer.stopButton.Enabled = False
    abufahmiPlayer.playButton.BackgroundImage = Global.abufahmiMediaPlayer.My.Resources.Resources.BTN_PLAY1
    abufahmiPlayer.Label1.Text = "Welcome to abufahmi Player ..."
    End If
    أعلم بان الموضوع طويل وهو مثله علي أنا وقد أرهقني كثيرا
    ولكنني حاولت شرح كل شيء وانا نتأكد باني لم ألبي كل شيء
    لذا العفو علي التقصير


    الملفات (dll) المرفقة بالموضوع تجدونها بالمرفقات
    بالإضافة الي البرنامج الناتج
    وأيضا سورس البرنامج موضوع الدرس


    هذا كل شيء وعلي المحبة نلتقي بمواضيع أخري بحول الله
    والسلام عليكم ورحمة الله وبركاته




  • عماد سعيد السيد
    Free Membership
    • Sep 2018 
    • 20 

    #2
    مبدع
    Comment
    Working...
    X