Notifications
Clear all

[Closed] dotnet windows media player

Hi,

I would like to add a windows media player within a rollout.

I found this page

http://msdn.microsoft.com/en-us/library/system.windows.media.videodrawing.player.aspx#Y570

mPlayer = dotNetObject "System.Windows.Media.MediaPlayer"
vDraw = dotNetObject "System.Windows.Media.VideoDrawing"
rect = dotNetObject "System.Windows.Rect" 0 0 580 580
vDraw.rect = rect
vDraw.Player = mPlayer

But I don’t know what control I ve to use to put it into my rollout.

10 Replies

how about a WPF version?

dotNet.loadAssembly @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll"
 
rollout WpfMediaTest "WPFMediaElement" width:362 height:254
(
 local WPFme
 dotNetControl Ehost "Integration.ElementHost" pos:[3,2] width:358 height:212
 button btnPlay "Play" pos:[6,221] width:78 height:26 border:false
 button btnStop "Stop" pos:[87,221] width:78 height:26 border:false
 
 on WpfMediaTest open do 
 (
 Ehost.backcolor = (dotnetclass"System.drawing.color").black
 WpfMe= dotnetobject "System.Windows.Controls.MediaElement"
  local uri = dotnetobject "System.Uri"  (getdir #preview + "\\_scene.avi")
  WpfMe.source = uri 
  Ehost.child = WpfMe
  WpfMe.LoadedBehavior = WpfMe.LoadedBehavior.manual 
 )
 
 on btnplay pressed do WpfMe.Play()
 on btnstop pressed do WpfMe.stop()
 
 on WPfMediatest close do 
 (
  WpfMe = undefined
  dgc = dotnetclass "system.gc"
  dgc.collect()
  gc() 
 ) 
)
createdialog  WpfMediaTest

^, that’s what I was thinking, but had no idea how to do in MXS. Very very cool

Edit: I just tested, and it was working, but I got a protected memory error on the wpfMe, EHost stuff, and max eventually crashed.

thx a lot.
you really helped me with your answer.

in max9 I had the same problem. when WpmfMe var is assinged
Ehost.child = WpfMe
then
–Rutime error: dotnet rutime exception: Atempt to redad write protected memory.

try to increase your heapSize.

1 Reply
(@merlinel)
Joined: 11 months ago

Posts: 0

I tryed heapsize 20680000L, but crashed again.

Hey guys, wrote this code in Max2011, hadn’t noticed the issues you’re mentioning.

same for me, not problems at all with max 2011.

 btw, when I try to get the media length,
WPFme.NaturalDuration.TimeSpan.TotalMilliseconds
 I have this error
Unable to return a TimeSpan property value for a Duration value of 'Automatic'
 How could I change the duration value to not be "Automatic"
all my files are on my hard drives

if I play the video, I can access it.
I will try to get it on an other way

edit: doesn’t work anymore…

I was testing on Max 2010 32bit. I have 2012/2011, but haven’t tried on those, I might in a few hours.