unfreakin belivable....You CAN run a MP4 file if you set the source in the xaml file with this<MediaElement x:Name="mPlayer2" Width="300" Height="250" AutoPlay="True" Source="/Videos/halo.mp4"/>
You CANNOT run the same file through MainPage.xaml.vb page with this' Set Medial Player Source
Dim Address = New Uri(Application.Current.Host.Source, "../Videos/halo.mp4")
'Dim Address = New Uri(Application.Current.Host.Source, "/Videos/halo.mp4")
'Dim Address = New Uri(Application.Current.Host.Source, "Videos/halo.mp4")
mPlayer2.Source = Address
' Start Media Player
mPlayer2.Stop()
mPlayer2.Play()
I change the soruce to a wmv file and was sucessful in setting the source from the mainpage.xaml.vb page...as such' Set Medial Player Source
Dim Address = New Uri(Application.Current.Host.Source, "../Videos/halo.wmv")
mPlayer2.Source = Address
' Start Media Player
mPlayer2.Stop()
mPlayer2.Play()
Curious to see what other files fall into this category....As for me ...the code I used look at entry #27 ...Its all laid out...there are 5 parts...2 in the xaml page and 3 in the vb page.Xaml: Set the Button in the map tip to call the classes create in vbSet the media elementVBcreate a new class "MapTipValueCommand1"Add #Region "Intersect command" code to main class in MainPage.xaml.vb Add the sub thats called from Class "MapTipValueCommand1" to set the media source...If anyone has any questions or comments please feel free to contact me at jaykappy@yahoo.comdoc ock I CANNOT THANK YOU ENOUGH....your help is very very appreciated...I cant believe that it boiled down to the media type...was so confused because the mp4 would play if the source was set in xaml....unbelievable....but thank you again....thank you for your patience and help....just in time for the weekend.....yaaaaa hooooooooooOne last thought....in the "Public Sub PlayVideo" where you are setting the source this is what I have..replace this with what you see in entry #27...remember you are retireving the value "videoName" from the new class videoName is the variable from pass to this sub from the Class, its in the class that you tell what field name to grab....in my case I have a field named "video""Videos" seen below is the folder I created in my project...I then right clicked it adn addded and existing file...by pointing to the Video....it then brings it into the project....
Public Sub PlayVideo(ByVal videoName As String)
'MessageBox.Show(videoName)
Dim Address = New Uri(Application.Current.Host.Source, "../Videos/" + videoName + ".wmv")
Me.mPlayer3.Source = Address
End Sub
Notice in the xaml in forum entry #27 there are additional buttons to start, stop, pause etc....and there are two calls for Element_MediaOpened3 and Element_MediaEnded3 and finally SeekToMediaPosition3Here is the vb code for that Private Sub bPlay_Click3(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
mPlayer3.Stop()
mPlayer3.Play()
End Sub
Private Sub bPause_Click3(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
If mPlayer3.CurrentState = MediaElementState.Paused Then
mPlayer3.Play()
Else
mPlayer3.Pause()
End If
End Sub
Private Sub bStop_Click3(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
mPlayer3.Stop()
End Sub
Private Sub bHide_Click3(ByVal sender As Object, ByVal e As EventArgs)
mPlayer3.Stop()
HideMedia3PlayerPanelNew.Begin()
End Sub
' When the media opens, initialize the "Seek To" slider maximum value
' to the total number of miliseconds in the length of the media clip.
Private Sub Element_MediaOpened3(ByVal sender As Object, ByVal args As RoutedEventArgs)
timelineSlider3.Maximum = mPlayer3.NaturalDuration.TimeSpan.TotalMilliseconds
End Sub
' When the media playback is finished. Stop() the media to seek to media start.
Private Sub Element_MediaEnded3(ByVal sender As Object, ByVal args As RoutedEventArgs)
mPlayer3.Stop()
End Sub
' Jump to different parts of the media (seek to).
Private Sub SeekToMediaPosition3(ByVal sender As Object, ByVal args As RoutedPropertyChangedEventArgs(Of Double))
Dim SliderValue3 As Integer = CType(timelineSlider3.Value, Integer)
' Overloaded constructor takes the arguments days, hours, minutes, seconds, miniseconds.
' Create a TimeSpan with miliseconds equal to the slider value.
Dim ts As New TimeSpan(0, 0, 0, 0, SliderValue3)
mPlayer3.Position = ts
End Sub