473,657 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MediaPlayer coding question


Hi,

I modified a thumbnail creation app and get black images since the first second is black as well.

My questions are:

1. How do I set the MediaPlayer.Clo ck property to start screen capture at two seconds?
2. How do I open a file without using a URI?

Here's the sample code:

private void CreateThumbnail (string file, string outputDir)
{
try
{

Uri uri = new Uri(file);

MediaPlayer mp = new MediaPlayer();
mp.Open(uri);
//mp.Position = new TimeSpan(00, 00, 02);
mp.Clock = new MediaTimeline(n ew TimeSpan(00, 00, 02)).CreateCloc k();
RenderTargetBit map rtb = new RenderTargetBit map(320, 240, 1 / 200, 1 / 200, PixelFormats.Pb gra32);
DrawingVisual dv = new DrawingVisual() ;
DrawingContext dc = dv.RenderOpen() ;
// RectAnimation ra = new RectAnimation() ;
// ra.BeginTime = new TimeSpan(00, 00, 02);
// dc.DrawVideo(mp , new Rect(0, 0, 320, 240), ra.CreateClock( ));
dc.DrawVideo(mp , new Rect(0, 0, 320, 240));

dc.Close();
rtb.Render(dv);
//Image im = new Image();
//im.Source = BitmapFrame.Cre ate(rtb);

string filename = GetFileName(fil e);

//create the output filename
object[] formatParams = new object[2];
formatParams[0] = outputDir;
formatParams[1] = filename;

string outputFileName = null;

outputFileName = string.Format(" {0}\\tn_{1}.bmp ", formatParams);

BmpBitmapEncode r encoder = new BmpBitmapEncode r();
encoder.Frames. Add(BitmapFrame .Create(rtb));

using (FileStream writer = new FileStream(outp utFileName, FileMode.Create ))
{
System.Console. WriteLine("Savi ng [{0}]", outputFileName) ;
encoder.Save(wr iter);
}
}
catch (Exception e)
{
System.Console. WriteLine("Crea teThumbnail: " + e.Message);
System.Environm ent.Exit(1);
}
}

Any suggestions?

Thanks,
William Johnston

Feb 8 '08 #1
1 3168
"William Johnston" <wi******@tenba se2.comwrote:
>
Still getting black thumbnails after setting BeginTime for MediaTimeLine object.

Here is my modifed thumbnail creator code:

private void CreateThumbnail (string file, string outputDir)
{
try
{
MediaPlayer mp = new MediaPlayer();

MediaTimeline mt = new MediaTimeline(n ew Uri(file));
mt.BeginTime = new TimeSpan(00, 00, 02);
MediaClock mc = mt.CreateClock( );

string beginTime = null;

if (debug)
{
beginTime = mc.Timeline.Beg inTime.ToString ();
System.Console. WriteLine("begi nTime: [" + beginTime + "]");
}

mp.Clock = mt.CreateClock( );

if (debug)
{
beginTime = mp.Clock.Timeli ne.BeginTime.To String();
System.Console. WriteLine("begi nTime: [" + beginTime + "]");
}

RenderTargetBit map rtb = new RenderTargetBit map(130, 92, 1 / 200, 1 / 200, PixelFormats.Pb gra32);
DrawingVisual dv = new DrawingVisual() ;
DrawingContext dc = dv.RenderOpen() ;
RectAnimation ra = new RectAnimation() ;
dc.DrawVideo(mp , new Rect(0, 0, 130, 92));

dc.Close();
rtb.Render(dv);

string filename = GetFileName(fil e);

//create the output filename
object[] formatParams = new object[2];
formatParams[0] = outputDir;
formatParams[1] = filename;

string outputFileName = null;

outputFileName = string.Format(" {0}\\tn_{1}.bmp ", formatParams);

BmpBitmapEncode r encoder = new BmpBitmapEncode r();
encoder.Frames. Add(BitmapFrame .Create(rtb));

using (FileStream writer = new FileStream(outp utFileName, FileMode.Create ))
{
System.Console. WriteLine("Savi ng [{0}]", outputFileName) ;
encoder.Save(wr iter);
}
}
catch (Exception e)
{
System.Console. WriteLine("Crea teThumbnail: " + e.Message);
System.Environm ent.Exit(1);
}
}

Thanks,
William Johnston

Feb 11 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2124
by: MLH | last post by:
The A97 set of controls has one at the end entitled "More Controls". Clicking it produces a host of ActiveX and OCX controls that can be dropped onto a form just as easily as a textbox. One of them is the MediaPlayer.MediaPlayer.1 control. I am able to select the control and place it onto a form. But I don't know how to configure it for use on a form. I was wondering where I could go to read more about it on the web?
0
1451
by: DotNetMania | last post by:
hi.. i have some questions about media player article on codeproject website...... http://www.codeproject.com/cs/media/directshowmediaplayer.asp?df=100&forumid=4399&select=820191#xx793428xx i have a media player class..
6
2004
by: Sjaakie Helderhorst | last post by:
Hi, I've been fooling around (noob) with VB.NET and put together a remote-controlled Mediaplayer-based 'server'. Had some troubles configuring interop on Windows XP with VS.NET 2003, but eventually things worked. Problem is I can't run the built output on any computer other than my own.... 'exception occured'. (Isn't VB.NET supposed to include all references when 'copy local' is set to true?) Anyone familiar with this problem (seems...
2
5203
by: Dick | last post by:
Hello, I've written a program that uses the Windows Mediaplayer. There are 2 files generated in my Bin folder: AxInterop.WMPLib.dll Interop.WMPLib.dll When running in the vb.net ide it works.
0
1720
by: Nonee | last post by:
Hello- I have a form with the mediaplayer referenced to play mp3's and avi's and I believe that is what is causing the problem. I am not sure, but I am hoping. Anyway, I "published" the vb.net app and moved it to another computer and I get the following error msg when I load the form with the mediaplayer on it. I upgraded this project from a standard vb app to the .net version (vb express anyway) and that is when the problem arose. ...
3
1930
by: MikeY | last post by:
From my understanding when exporting your app.exe with a mediaplay hooked up, you must also place a copy of AxInterop.WMPLib.dll and Interop.WMPLib.dll" wrapper class. to the location of my app.exe. Is there something better out there I should be using to avoid this and or a better way of doing this so that I don't have to export the .dll's. Any and all help is appreciated. MikeY
7
3378
by: xhunter | last post by:
ok here is my problem, I am trying to change the source file of the mediplayer using javascript, my script works perfectly in "Internet Explorer", but no matter what I do, it doesn't work in Firefox here is my player : <OBJECT classid=CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95 height=276 id=mediaPlayer type=application/x-oleobject width=320 standby="Loading Video..."> <embed
3
2964
by: William Johnston | last post by:
Hello, How do I explictly destruct a MediaPlayer object? The compiler complained about overriding Finalize. MediaPlayer does not implement IDisposable. Any suggestions? Thanks,
0
8316
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.