?
Solved

Do my app need to have windows media player to use axwindowsmediaplayer in Visual Basic?

Posted on 2016-10-23
6
Medium Priority
?
192 Views
Last Modified: 2016-11-09
Hello,

I've made an app to listen to some radio streams using AxWindowsMediaPlayer. I'm using Visual Basic in Visual Studio 2015. So far, it works in a couple testing computers running Windows 10 but not in a computer running a fresh Windows 7.

That Win7 computer is not in my reach so I can't fully test everything but my guess is that Windows Media Player is not installed or initialized? Could that be it?

What I wonder is if WMP needs to be installed in the target computers (which is kinda obvious) but also initialized? I remember in Windows 7 WMP asked a bunch of questions the first time you opened it.

If that's so, is there some way to include some prerequisites with my app so that wouldn't matter?

Thanks in advance!
0
Comment
Question by:Cesar Aracena
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 41856422
use the direct-x direct sound or .net framework instead
0
 
LVL 28

Expert Comment

by:Ark
ID: 41859646
Create custom control (Name = "MediaPlayer") and put WebBrowser (Dock=Fill, Name= "wbMedia") on it.
Imports System.Text
Imports System.ComponentModel

Public Class MediaPlayer
    Private _url As String, _autoPlay, _loop As Boolean

    Private Sub MediaPlayer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim sbMedia As New StringBuilder
        sbMedia.AppendLine("<OBJECT ID='MediaPlayer' width=100% height=100% ")
        sbMedia.AppendLine("CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'>")
        sbMedia.AppendLine("</OBJECT>")
        wbMedia.DocumentText = sbMedia.ToString
    End Sub
    <Editor(GetType(System.Windows.Forms.Design.FileNameEditor), GetType(System.Drawing.Design.UITypeEditor))> _
    Public Property MediaPath() As String
        Get
            Return _url
        End Get
        Set(ByVal value As String)
            _url = value
            If wbMedia.Document Is Nothing Then Return
            Dim player As Windows.Forms.HtmlElement = wbMedia.Document.GetElementById("MediaPlayer")
            If player Is Nothing Then Return
            player.SetAttribute("URL", _url)
        End Set
    End Property
    Public Property AutoStart() As Boolean
        Get
            Return _autoPlay
        End Get
        Set(ByVal value As Boolean)
            _autoPlay = value
            If wbMedia.Document Is Nothing Then Return
            Dim player As Windows.Forms.HtmlElement = wbMedia.Document.GetElementById("MediaPlayer")
            If player Is Nothing Then Return
            player.DomElement.settings.autostart = _autoPlay
        End Set
    End Property
    Public Property AutoRepeat() As Boolean
        Get
            Return _loop
        End Get
        Set(ByVal value As Boolean)
            _loop = value
            If wbMedia.Document Is Nothing Then Return
            Dim player As Windows.Forms.HtmlElement = wbMedia.Document.GetElementById("MediaPlayer")
            If player Is Nothing Then Return
            player.DomElement.settings.setMode("loop", _loop)
        End Set
    End Property

    Public Sub StopPlaying()
        If wbMedia.Document Is Nothing Then Return
        Dim player As Windows.Forms.HtmlElement = wbMedia.Document.GetElementById("MediaPlayer")
        If player Is Nothing Then Return
        player.DomElement.controls.stop()
    End Sub

    Private Sub wbMedia_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wbMedia.DocumentCompleted
        If wbMedia.Document Is Nothing Then Return
        Dim player As Windows.Forms.HtmlElement = wbMedia.Document.GetElementById("MediaPlayer")
        If player Is Nothing Then Return
        wbMedia.Document.Body.Style = "margin:0px;padding:0px"
        If Not player.GetAttribute("URL").Equals(_url, StringComparison.OrdinalIgnoreCase) Then
            player.SetAttribute("URL", _url)
        End If
        If Not player.DomElement.settings.autostart.Equals(_autoPlay) Then
            player.DomElement.settings.autostart = _autoPlay
        End If
        If Not player.DomElement.settings.getMode("loop").Equals(_loop) Then
            player.DomElement.settings.setMode("loop", _loop)
        End If
    End Sub
End Class

Open in new window

You can add some properties/methods as well. See: https://msdn.microsoft.com/en-us/library/windows/desktop/dd564034(v=vs.85).aspx and/or
https://msdn.microsoft.com/en-us/library/windows/desktop/dd562656(v=vs.85).aspx
0
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 41859806
@ARK your solution requires the windows media player to be on the client machine better to just use .net classes
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:Ark
ID: 41859808
If it's not on client machine webbrowser prompt user to download it
0
 
LVL 6

Author Comment

by:Cesar Aracena
ID: 41860504
@Ark: I really would prefer the embedded Windows Media Player instead of a web browser.

@David: I can't find anything about .net supporting AAC codec. Just WAV and MP3. Can you point me please to any info on this? Thanks ;)
0
 
LVL 82

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 total points
ID: 41880888
the .net classes will use the codecs installed on the machine. AAC codec should be installed already on the machine without WMP being installed. It has been my experience that people that don't have WMP installed by default will elect to install it right off the top. Either that or they will have another media player installed. The difference with the N versions is that WMP is not installed by default and the user is given a choice
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question