Tech Off Thread

21 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

<MediaElement> in XAML

Back to Forum: Tech Off
  • User profile image
    bander

    The <MediaElement Source="C:\mymovie.wmv"></MediaElement> is not working!!!!

    I'm using the latest CTP that works with VS RTM...
    Simply I get a black shape instead of the movie as if it's not loaded.

    Anybody got a clue? Perplexed

  • User profile image
    andokai

    If it's a video that you downloaded from the internet then it's protected and doesn't run. Go to the video's properties and select unblock and see if that works.

  • User profile image
    geekling

    There've been some changes in the most recent CTPs.

    http://winfx.members.winisp.net/files/introductionnovctp.mht

    Has some infformation about changes to MediaElement and MediaPlayer

  • User profile image
    bander

    andokai wrote:
    If it's a video that you downloaded from the internet then it's protected and doesn't run. Go to the video's properties and select unblock and see if that works.


    I can't find this unblock thing!
    Please edify

  • User profile image
    andokai

    Right click on the video go to properties. The unblock button should be on the bottom right. If it's not there then it's not blocked and it's a different problem.

    If it's not that I would suggest checking with a few different types of clips to see whether it's a general problem or file specific.

  • User profile image
    bander

    not a single wmv file in my machine has an unblock button..
    I have tried running the MediaElement over several machines, all the same, a blank screen, check out the screen shot below:

    * I'm using the RTM


  • User profile image
    andokai

    Ok well I copied your markup exactly and everything works fine. I am using VS 2005 RTM also with the WPF December CTP. I am running out of ideas as to what it could be. It's certainly unusual that it's happening on all machines and with all clips.

    Try download this halo wmv. I have plugged it into the markup you already listed and it works fine. If it doesn't work for you then I give up. As a matter of interest, what version of Windows Media Player do you have installed?

  • User profile image
    AndyC

    I was getting the same thing on my tablet (which has WMP10 and IE7 installed), but it works fine on this desktop (pretty much an OOB XPSP2 install + WPF CTP)

    Curious...

  • User profile image
    bander

    I have Windows Media Player 9
    I'll try installing 10 and playing the Halo video then get back to you..

  • User profile image
    bander

    It's working, yepeeeeeeeeeeeeeeeeeee Tongue Out

    I guess the reason was Media Player 9!

  • User profile image
    andokai

    Good to hear and glad I could help. Big Smile

  • User profile image
    bander

    Another problem Perplexed

    <MediaElement Source="C:\m.wmv" RenderTransform="rotate 50"></MediaElement>

    I get this message from XAMLPAD:
    "Error at element 'MediaElement' in markup file '' : The string 'rotate 50' could not be set on the 'RenderTransform' property which is of type 'Transform'. Please see the sdk documentation for the RenderTransform property and the Transform class for an explanation of allowable values. Line 28 Position 84."

    I also tried it on VS2005 RTM, when trying to run it is terminated by the OS, and the famous Watson dialog appear asking me to send the report.

    *PS: I tried writting rotate with a capital "R", the same error appears!

  • User profile image
    geekling

    bander wrote:
    Another problem

    <MediaElement Source="C:\m.wmv" RenderTransform="rotate 50"></MediaElement>

    I get this message from XAMLPAD:
    "Error at element 'MediaElement' in markup file '' : The string 'rotate 50' could not be set on the 'RenderTransform' property which is of type 'Transform'. Please see the sdk documentation for the RenderTransform property and the Transform class for an explanation of allowable values. Line 28 Position 84."

    I also tried it on VS2005 RTM, when trying to run it is terminated by the OS, and the famous Watson dialog appear asking me to send the report.

    *PS: I tried writting rotate with a capital "R", the same error appears!


    The transform mini language is gone in the newest CTPs. You'll have to do the fully qualified XML.


  • User profile image
    andokai

    Yeah they seem to be scrapping much of the mini-language for a more verbose way to describe properties. to do a rotation you might need to do something like this;

    <MediaElement Source="C:\m.wmv">
       <MediaElement.RenderTransform>
           <RotateTransform CenterX="25" CenterY="50" Angle="45" />
       </MediaElement.RenderTransform>
    </MediaElement>

  • User profile image
    bander

    Thanks..
    Found all other answers in th release notes Big Smile

  • User profile image
    MDeevi

    Hi,

    Even I am also facing same problem (i.e. Getting a black screen instead of playing a WMV file) even after installing Windows Media Player 10 on my Desktop machine having Windows XP SP2, VS 2005 RTM and WinFX Dec 2005 CTP. Please provide some solution in what way I can resolve this Problem.

    Here is my XAML Code:

    <DockPanel Name="DockPanel1" xmlns="http://schemas.microsoft.com/winfx/avalon/2005" xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005">
      <MediaElement Height="350" Source="C:\MediaFiles\Sample.wmv" Width="200" Name="MediaElement1" />
    </DockPanel>

    Thanks in advance,
    MDeevi.

     

  • User profile image
    Kosher

    I'm running the February CTP of WinFX and I get an error sometimes and other times it's just blank.  In either case I am unable to see the video.

    The code:

    <MediaElement x:Name="MyMedia" Source="file:\\\C:\Documents and Settings\Tommy\Desktop\billg_sheilagu.wmv" LoadedBehavior="Play"/>

    The error I get is:
    No operations are valid on a closed media player except open and close.

    The error only occurs once in a while but the main issue is not being able to see the video.  I unblocked the video by going to the properties and clicking the unblock button but still no love.

    Any tips?

    Thanks,
    <T>

  • User profile image
    Kosher

    FYI:

    I tried this code as well:

    <Grid

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:c="http://schemas.openxmlformats.org/markup-compatibility/2006"

    xmlns:d="http://schemas.microsoft.com/expression/interactivedesigner/2006"

    c:Ignorable="d"

    Background="#FFFFFFFF"

    x:Name="DocumentRoot"

    x:Class="UntitledProject2.Scene1"

    Width="640" Height="480">

    <Grid.Resources>

    <Storyboard x:Key="OnLoaded"/>

    </Grid.Resources>

    <Grid.Triggers>

    <EventTrigger RoutedEvent="Button.Click" SourceName="playButton">

    <EventTrigger.Actions>

    <BeginStoryboard Name= "myBegin">

    <Storyboard>

    <MediaTimeline Source="file:\\\C:\Documents and Settings\Tommy\Desktop\Halo2v3_Low_640.wmv" Storyboard.TargetName="myvideo"/>

    </Storyboard>

    </BeginStoryboard>

    </EventTrigger.Actions>

    </EventTrigger>

    <EventTrigger RoutedEvent="Button.Click" SourceName="pauseButton">

    <EventTrigger.Actions>

    <PauseStoryboard BeginStoryboardName="myBegin" />

    </EventTrigger.Actions>

    </EventTrigger>

    </Grid.Triggers>

    <Grid.ColumnDefinitions>

    <ColumnDefinition/>

    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>

    <RowDefinition/>

    </Grid.RowDefinitions>

    <StackPanel>

    <MediaElement Name="myvideo"/>

    <Button Name="playButton" >Play</Button>

    <Button Name="pauseButton" >Pause</Button>

    </StackPanel>

    </Grid>

    Same errors as mentioned in previous post.  Sometimes it's blank, other times it says:

    "No operations are valid on a closed media player except open and close."
    "   at MS.Internal.HRESULT.Check(Int32 hr)\r\n   at System.Windows.Media.MediaPlayer.SetPosition(TimeSpan value)\r\n   at System.Windows.Media.MediaClock.Sync()\r\n   at System.Windows.Media.MediaClock.SpeedChanged()\r\n   at System.Windows.Media.Animation.Clock.RaiseAccumulatedEvents()\r\n   at System.Windows.Media.Animation.TimeManager.RaiseEnqueuedEvents()\r\n   at System.Windows.Media.Animation.TimeManager.Tick()\r\n   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)\r\n   at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)\r\n   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)\r\n   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)\r\n   at System.Windows.Threading.DispatcherOperation.InvokeImpl()\r\n   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)\r\n   at System.Threading.ExecutionContext.runTryCode(Object userData)\r\n   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)\r\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Windows.Threading.DispatcherOperation.Invoke()\r\n   at System.Windows.Threading.Dispatcher.ProcessQueue()\r\n   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)\r\n   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)\r\n   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)\r\n   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)\r\n   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)\r\n   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)\r\n   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)\r\n   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)\r\n   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)\r\n   at System.Windows.Threading.Dispatcher.Run()\r\n   at System.Windows.Application.RunInternal(Window window)\r\n   at System.Windows.Application.Run(Window window)\r\n   at System.Windows.Application.Run()\r\n   at UntitledProject2.MainApplication.Main() in C:\\Documents and Settings\\Tommy\\My Documents\\Interactive Designer Projects\\TestVideo\\obj\\Debug\\Application.g.cs:line 50\r\n   at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)\r\n   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.ThreadHelper.ThreadStart()"

    Thanks,
    <T>

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.