c# - Adding MediaElement to canvas -


im trying create overlay system media items. add canvas form. via code add media element canvas.

mediaplayer = new mediaelement(); canvas.children.add(mediaplayer); mediaplayer.horizontalalignment = horizontalalignment.left; mediaplayer.verticalalignment = verticalalignment.top; mediaplayer.height = 1080; mediaplayer.width = 1920; mediaplayer.source = new uri(configurationmanager.appsettings["videofile"], urikind.relative);  mediaplayer.loadedbehavior = mediastate.manual;  mediaplayer.play(); mediaplayer.mousedown +=mediaplayer_mousedown; 

when launch app exception on canvas.children.add(mediaplayer): object reference not set instance of object. not mather if place line after instantiate, right before play() call or after play() call.

i did tests, when adding in designer works, though not alow start maunally, when setting loadedbehavior manual crashes (same error). when adding media element form work expected, though cannot overlay elements... doing wrong?

the problem not code above. problem in wpf need call initializecomponent. method standard generated when creating new form. accident removed line of code. causes form elements not initialized.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -