i'm using visual studio 2010, c# wpf. have created mediaelement
control during runtime;
mediaelement video= new mediaelement(); video.width = 400; video.height = 400; video.play(); video.source = new uri(path, urikind.relative);
in xaml view created 2 buttons, play , stop show visible if mediaelement created. need add click_events these 2 buttons. when write video.play();
not know name. know how name recognised in these seperate methods?
private void play_click(object sender, routedeventargs e) { video.play(); //syntax error under video } private void stop_click(object sender, routedeventargs e) { video.play(); //syntax error under video }
you need define video
member variable. example, you're in class called mediawindow
...
public class mediawindow { private mediaelement video = new mediaelement { width = 400, height = 400}; public void setvideosource(string path) { video.source = new uri(path, urikind.relative); } private void play_click(object sender, routedeventargs e) { video.play(); } private void stop_click(object sender, routedeventargs e) { video.stop(); } }
adjust actual class structure , setup.
Comments
Post a Comment