JOHN JOHNNNY

JOHN JOHNNNY

  • NA
  • 190
  • 134.9k

WP8: Playing midi file in custom message box

Jan 22 2016 5:45 AM

Hi

I tried playing midi file in my windows phone 8 app but got no result, is there a way to play midi files in my app.
when user click on the text in listbox, cmb appears that shows the play button.My midi file is in my
root folder/assets
see my code below

xaml

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

<ListBox>
<ListBoxItem Height="80" Tap="Item1_Tapped">
<Border BorderThickness="0,0,0,1" BorderBrush="#c0c0c0" >
<Grid Width="430">
<Image Height="40" Width="40" Source="Assets/music.png" Margin="0,15,390,24" />
<TextBlock VerticalAlignment="Center" Foreground="Black" FontSize="30" Margin="49,15,55,24">Hymn 1 O Lord my ...</TextBlock>
<Image Height="40" Width="30" Source="Assets/right_black.png" Margin="383,30,17,9"/>
</Grid>
</Border>
</ListBoxItem>
</ListBox>

</Grid>

xaml.cs

CustomMessageBox cmb;
private void Item1_Tapped(object sender, System.Windows.Input.GestureEventArgs e)
{
// create new Stack panel
StackPanel sp = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Vertical };

//get policy text from file
string hymns = getHymn1();

//Create new label
TextBlock tb = new TextBlock()
{
Text = hymns,
TextWrapping = TextWrapping.Wrap,
FontSize = 20,

};

//Create new Scroll viewer
ScrollViewer sv = new ScrollViewer()
{
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
Height = 700,
};

// add texblock in scroll viewer
sv.Content = tb;

//Add the controls to stack panel
sp.Children.Add(sv);

cmb = new CustomMessageBox()
{
// Set its content
Content = sp,
Opacity = 15.0,


// Left button of message box Button
LeftButtonContent = "Back",

// Right button of message box
RightButtonContent = "Play" //Play MIDI file here when clicked


};

//Show the message box...
cmb.Show();
}

private string getHymn1()
{
using (StreamReader s = new StreamReader("Hymn1.txt"))
{
return s.ReadToEnd();
}
}

Kindly help