所以有人请告诉我当我点击列表框中的特定歌曲时如何播放视频。我已经解析了RSS提要并在列表框中显示了所有视频..
我有一个名为Songsdetails的类,其属性很少
public class Songsdetails
{
public string songname { get; set; }
public string songpic { get; set; }
public string songurl { get; set; }
public string songcode { get; set; }
public string songdescr { get; set; }
public string songtitletags { get; set; }
public string songmetatags { get; set; }
public string songmetadesc { get; set; }
public string songdate { get; set; }
}
我通过以下过程将此歌曲代码称为Videopage.Xaml.cs。但是没有调用歌曲代码。变量中存在Null。
namespace videosongs
{
public partial class Videopage : PhoneApplicationPage
{
// Constructor
public Videopage()
{
InitializeComponent();
Songsdetails songdetails=new Songsdetails();
string code = songdetails.songcode;
string video = "http://www.youtube.com/embed/"+code;
System.Diagnostics.Debug.WriteLine(video);
this.webBrowser.Navigate(new Uri(video));
}
请有人帮忙如何获取歌曲码。我不明白为什么歌曲码不会出现。 通过这首歌曲代码视频将在模拟器中播放。 请任何人帮忙是错误的。如何获得歌曲码值。 三江源。
namespace videosongs
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
// is there network connection available
if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
{
MessageBox.Show("No network connection available!");
return;
}
// start loading XML-data
WebClient downloader = new WebClient();
Uri uri = new Uri("http://www.teluguone.com/videosongs/videoSongsXml.php?cat_id=6", UriKind.Absolute);
downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(VideosongsDownloaded);
downloader.DownloadStringAsync(uri);
}
void VideosongsDownloaded(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Result == null || e.Error != null)
{
MessageBox.Show("There was an error downloading the XML-file!");
}
else
{
//Deserialize if download succeeds
{
XDocument document = XDocument.Parse(e.Result);
XmlSerializer serializer = new XmlSerializer(typeof(Videosongs));
Videosongs videosongs = (Videosongs)serializer.Deserialize(document.CreateReader());
videosongList.ItemsSource = videosongs.Collection;
}
}
}
private void videosongList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listBox = sender as ListBox;
if (listBox != null && listBox.SelectedItem != null)
{
Songsdetails song = (Songsdetails)listBox.SelectedItem;
NavigationService.Navigate(new Uri("/Videopage.xaml", UriKind.Relative));
}
}
}
} videosongs类
namespace videosongs
{
[XmlRoot("videosongs")]
public class Videosongs
{
[XmlElement("songsdetails")]
public ObservableCollection<Songsdetails> Collection { get; set; }
}
答案 0 :(得分:0)
为您创建的数据载体类定义构造函数始终是一个好习惯。这将避免空指针异常。另外正如@germi所说,在这段代码中,邮件问题是你没有设置它。那你怎么用呢?
由于 阿伦