Adblock breaks this site

make a windows media player

Discussion in 'Programming General' started by kharg0, Apr 6, 2007.

  1. kharg0

    kharg0 Active Member

    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0
    make a windows media player

    any 1 got a tut on how to make a windows media player?

    If you only have a code thats ok but it would be better as a media player thx:)
    mostly towards x zero and cooladrang cuz they made 1

    alrighty today people c'mon some 1 plz answer
     
  2. cwade12c

    cwade12c Guest

    Referrals:
    0
    make a windows media player

    1) Press Ctrl+T
    2) Select Microsoft Windows Media Player
    3) Insert it
    4) Insert a List box and a file box
    5) Set List Box to only show: *mp3 , *wma
    6) Insert A Command Button
    7) As for the code... I don't have it at the moment, but if you don't get it from anybody else soon, email me:
    [email protected]
     
  3. kharg0

    kharg0 Active Member

    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0
    make a windows media player

    alright i worked on it and i searched through snippets is there anything wrong with this???

    PictureBox1.Image() = Image.FromFile(test.avi) thats to play a movie and

    Code:
    My.Computer.Audio.Play("ringout.wav, AudioPlayMode.WaitToComplete)
    thats for sound

    i cant get it to work perfectly yet tho some 1 help

    oh ya and cwade12c i dont understand a little more specific please
     
  4. nphp20

    nphp20 Guest

    Referrals:
    0
    make a windows media player

    I'm going to take a wild guess (well, not really, "PictureBox1.Image() = Image.FromFile(test.avi)" gives it away as VB6 doesnt use FromFile) and say you're using VB2005? If so, then I can't be of much use, but if you're using VB6 you can download my RS client's source code and look at the mp3 player (link is in signature.
     
  5. X Zero

    X Zero Forum Addict

    Joined:
    Jan 21, 2007
    Posts:
    577
    Referrals:
    0
    Sythe Gold:
    0
    make a windows media player

    wow, does that even work?
     
  6. kharg0

    kharg0 Active Member

    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0
    make a windows media player

    im pretty sure it only plays gifs ill try

    yup i tried it only plays gifs but the music will work

    so once again can anyone provide a tutorial for this??
     
  7. kharg0

    kharg0 Active Member

    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0
    make a windows media player

    ok i finally got sumthing to work go to your toolbox right click press choose items... when you get in press the com tab then go to almost the bottom where you find windows media player check it and press ok then it will be in your toolbox use it and it will make it look and work like windows media player

    one small problem tho i dont know how to use a openfiledialog to open things

    thx kharg0
     
  8. skate4lifee

    skate4lifee Active Member

    Joined:
    Jul 22, 2007
    Posts:
    108
    Referrals:
    1
    Sythe Gold:
    0
    make a windows media player

    this is pretty easy to make, like stated before add the windows media player control
    you also want to add an openfiledialog so you can browse for the file you want.
    first lets add the windows media player control to the form
    double click the openfiledialog to go to the code view and add this code:
    Code:
    try
                openfilediloag1.initialdirectory = "c:\"
                openfilediloag1.showdialog()
                axwindowsmediaplayer1.URL = openfilediloag1.filename
                axwindowsmediaplayer1.ctlcontrols.play()
            catch ex as exception
                messagebox.show("Some error occur so can't play media", "Error", messageboxbuttons.OK, messageboxicon.error)
            end try
    now lets move onto the play, stop and pause (this is not needed just extra)
    so add 3 buttons and name their text property play stop and pause

    for the play button:
    Code:
    axwindowsmediaplayer1.ctlcontrols.play()
    for the stop and pause button you will use the same code except replace "play" with pause and stop

    now we can do volume this is also optional because the windows media player control already has done this for you but this is good for learning =)

    so lets first start with raising the volume:
    Code:
    axwindowsmediaplayer1.settings.volume = axwindowsmediaplayer1.settings.volume + 10
    the same code will be used for lowering the volume except change the "+10" at the end to "-10"

    now if you would like to mute the volume add another button:
    Code:
    if axwindowsmediaplayer1.settings.volume = axwindowsmediaplayer1.settings.mute() then
    
                axwindowsmediaplayer1.settings.volume = 20
            else
                axwindowsmediaplayer1.settings.volume = axwindowsmediaplayer1.settings.mute()
            end if
    and that is the end of your simple media player using the windows media player control =)

    the code is pretty self explanatory, its almost like english so i doubt i will need to explain what any of it does but feel free to ask =)
     
  9. Mike2098

    Mike2098 Guest

    Referrals:
    0
    make a windows media player

    Hi thanks for the code do you know how I could use play file to play a file selected in a listbox ?

    Curently I have this

    Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlay.Click
    Dim i As Integer
    For i = 0 To lstFiles.SelectedIndices.Count - 1
    Next
    axWindowsMediaPlayer.URL = lstFiles.SelectedItem
    axWindowsMediaPlayer.Ctlcontrols.play()
    End Sub

    thanks

    Mike
     
  10. skate4lifee

    skate4lifee Active Member

    Joined:
    Jul 22, 2007
    Posts:
    108
    Referrals:
    1
    Sythe Gold:
    0
    make a windows media player

    X Zero helped me with this same question so thank X Zero for this.

    first add a listview to a new form or keep it on the same form, whatever you prefer. this listview will display the song and the location. i will also be adding code for playing the current song chosen upon double clicking.

    now you want to add an 'add' button and a 'remove' button.

    for the add button code you will add

    Code:
    On Error Resume Next
            Dim Multi() As String
            Dim FEn As IEnumerator
            Dim str(2) As String
            Dim itm As ListViewItem
            Dim path, Name As String
            Dim OpenDialog As New OpenFileDialog
            OpenDialog.Filter = "Supported Media (avi, mid, mp3, mpg, mpeg, mp4, wav, wma, wmv)|*.avi;*.mid;*.mp3; *.mpg; *.mpeg;*.mp4;*.wav;*.wma;*.wmv|Audio Media (*.mid, *.mp3, *.wav, *.wma|*.mid;*.mp3;*.wav;*.wma|Video Media (*.avi, *.mpg, *.mpeg, *.wmv)|*.avi;*.mpg;*.mpeg;*.wmv"
            OpenDialog.Multiselect = True
            If OpenDialog.ShowDialog = Windows.Forms.DialogResult.OK Then Multi = OpenDialog.FileNames
            If IsNothing(Multi) Then Exit Sub
            FEn = Multi.GetEnumerator
            FEn.Reset()
            While FEn.MoveNext
                str(1) = (CType(FEn.Current, String))
                path = (CType(FEn.Current, String))
                Dim x As Integer = path.LastIndexOf("\") + 1
                Dim mediaName As String = path.Substring(x)
                x = mediaName.LastIndexOf(".")
                mediaName = mediaName.Substring(0, x)
                Name = mediaName
                x = Nothing
                mediaName = Nothing
                str(0) = Name
                itm = New ListViewItem(str)
                ListView1.Visible = False
                ListView1.Items.Add(itm)
                ListView1.Visible = True
            End While
    for the remove button you will add

    Code:
    for i as integer = listview1.selecteditems.count - 1 to 0 step -1
    listview1.items.removeat(listview1.selecteditems(i).index())
    next
    now you are going to make a new sub called 'save list' so add this code

    Code:
        Sub save_list(ByVal list As ListView, ByVal filename As String)
            Dim info As String = ""
            Dim item As Integer
            For item = 0 To list.Items.Count - 1
                info = info & vbNewLine & list.Items(item).SubItems(1).Text
            Next
            FileIO.FileSystem.WriteAllText(filename, info, False)
        End Sub
    then you will add a load list sub

    Code:
    Sub load_list(ByVal list As ListView, ByVal filename As String)
            list.Items.Clear()
            Dim info() As String = Split(FileIO.FileSystem.ReadAllText(filename), vbNewLine)
            Dim item As Integer
            On Error Resume Next
            Dim Multi() As String
            Dim FEn As IEnumerator
            Dim str(2) As String
            Dim itm As ListViewItem
            Dim Name, path As String
            For item = 1 To UBound(info)
                If (info(item) <> "") Then
                    str(1) = (info(item))
                    Dim x As Integer = str(1).LastIndexOf("\") + 1
                    Dim mediaName As String = str(1).Substring(x)
                    x = mediaName.LastIndexOf(".")
                    mediaName = mediaName.Substring(0, x)
                    Name = mediaName
                    x = Nothing
                    mediaName = Nothing
    
                    str(0) = Name
                    itm = New ListViewItem(str)
                    list.Visible = False
                    list.Items.Add(itm)
                    list.Visible = True
                End If
            Next
        End Sub
    then upon closing the form you will add

    Code:
    save_list(ListView1, My.Application.Info.DirectoryPath & "\Library.txt")
    and upon opening the form you will add

    Code:
            If FileIO.FileSystem.FileExists(My.Application.Info.DirectoryPath & "\Library.txt") Then
                load_list(ListView1, My.Application.Info.DirectoryPath & "\Library.txt")
            Else
                FileIO.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & "\Library.txt", "", True)
            End If
    and lastly playing the selected item so go to the listview's double click to play the selected song

    Code:
    player.URL = (listview1.selecteditems(0).subitems(1).text)
    once again, this code was given to me by X Zero.

    X Zero i will gladly edit my post and remove this code if you prefer me not to post this.
     
  11. Mike2098

    Mike2098 Guest

    Referrals:
    0
    make a windows media player

    Wow thanks for the reply I sort of got it to work using

    Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlay.Click
    axWindowsMediaPlayer.Visible = (True)
    Dim i As Integer
    For i = 0 To lstFiles.SelectedIndices.Count - 1
    Next
    Try
    axWindowsMediaPlayer.URL = lstFiles.SelectedItem
    axWindowsMediaPlayer.Ctlcontrols.play()
    Catch ex As Exception

    End Try
    End Sub

    but when I go to play the file it uses the folder my project is in, rather than the original folder I loaded the file from any sugestions ?

    I can email the source to my project if needed


    the other thing I am havingtrouble with is getting the volume control to work using a ScrollBar

    many thanks

    Mike ;-)
     
  12. skate4lifee

    skate4lifee Active Member

    Joined:
    Jul 22, 2007
    Posts:
    108
    Referrals:
    1
    Sythe Gold:
    0
    make a windows media player

    if your having trouble playing a file then look at my previous post i wrote some code to show you how...and as for using a trackbar for volume is pretty easy. first obviously add a scroll bar then for the trackbar's scroll property add

    Code:
    axwindowsmediaplayer.settings.volume = trackbar1.value
     
  13. Mike2098

    Mike2098 Guest

    Referrals:
    0
    make a windows media player

    Great stuff all sorted thanks guy's
     
  14. Mike2098

    Mike2098 Guest

    Referrals:
    0
    make a windows media player

    ops double post sorry
     
  15. Mike2098

    Mike2098 Guest

    Referrals:
    0
    make a windows media player

    Ok I have drop box with audio and video as the options I want to be able to choose what panel is displayed

    Private Sub cmbAudioVideo_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbAudioVideo.DropDown
    If cmbAudioVideo = selectedItem.Video Then
    pnlVideo.Visible = True
    End If

    thanks

    Mike

    End Sub
     
  16. rattytatt50

    rattytatt50 Member

    Joined:
    Oct 26, 2007
    Posts:
    67
    Referrals:
    0
    Sythe Gold:
    0
    make a windows media player

    axwindowsmediaplayer isnt vb8. it said it isnt defined
     
  17. skate4lifee

    skate4lifee Active Member

    Joined:
    Jul 22, 2007
    Posts:
    108
    Referrals:
    1
    Sythe Gold:
    0
    make a windows media player

    sure it is, add a windows media player control and that will be the default name.
     
  18. rattytatt50

    rattytatt50 Member

    Joined:
    Oct 26, 2007
    Posts:
    67
    Referrals:
    0
    Sythe Gold:
    0
    make a windows media player

    how do i add a control?
     
  19. rattytatt50

    rattytatt50 Member

    Joined:
    Oct 26, 2007
    Posts:
    67
    Referrals:
    0
    Sythe Gold:
    0
    make a windows media player

    FOUND IT!! i had to choose an item in the toolbox :)
     
  20. rattytatt50

    rattytatt50 Member

    Joined:
    Oct 26, 2007
    Posts:
    67
    Referrals:
    0
    Sythe Gold:
    0
    make a windows media player

    yay it works! (sorry for double posting)
     
< Windows Account Creator! | keygens... >


 
 
Adblock breaks this site