Silverlight How to Set Volume of Background Music after video plays

Silverlight 5

Got an issue where I am playing background music for an application. Once a user navigates from the main page to another page, a video plays and the background music volume is set lower. I then have an event once that video ends but not sure how to reference the background music from the main page from this particular view to make it work the way I want.

Page with the video that plays looks something like this. I want to set the background music back to normal level. I know the code to use, just need to figure out how to reference the method from the main page.
namespace GG.Views
{ 
    public partial class MyPage2 : Page
    {

        public AttackStrategy()
        {
            InitializeComponent();
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {           
            ContentText.Text = "This page blah blah";
        }

        private void media_MediaEnded(object sender, RoutedEventArgs e)
        {
            //need to do something here.
        }


    }
}

Open in new window


Main Page code, need to call this method FadeInMusic
namespace GG
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            PlayMusic();
         }
        //blah blah more code here...
        public void FadeInMusic()
        {
            _music.Volume = 0.5;
        }

Open in new window



I tried the obvious to create an instance of the main page in the view and call the method but it just plays the music again so I now have 2 instances of the music playing. how to fix this?

        private void media_MediaEnded(object sender, RoutedEventArgs e)
        {
            MainPage test = new MainPage();
            test.FadeInMusic();
        }

Open in new window

LVL 1
mathew_sAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
how do you lower the volume, simply invert it
0
mathew_sAuthor Commented:
Yes I know how to set the volume back to normal level. Question is how to call the method from the view page without creating 2 instances of the music playing which currently is what happens. If I create a new instance of mainpage it will play the music again so I have the music playing twice in the background. How to get around this?
0
mathew_sAuthor Commented:
Got it to work the way I wanted it to by creating the mediaelement as an app variable.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mathew_sAuthor Commented:
Solved it myself.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.