Using Arrays to Store Song Data In this part of the project you will use arrays to store the song data and then use a web brows
Using Arrays to Store Song Data
In this part of the project you will use arrays to store the song data and then use a web browser to open the URLs for each song. Read the Project Guide provided and the project video link for instructions and details to help guide you through your efforts.
Course Project DeVry University College of Engineering and Information Sciences
Screenshot of program running:
Form code (only the code for the form, not program.cs):
,
Course Project DeVry University College of Engineering and Information Sciences
Course Number: CEIS209
Background
Part 1: Scenario
Lucky you! Your manager has put you in charge of the lyrics videos for the monthly lip synch contest. Each contestant “sings” along with a song of their choice, prompted by the lyrics in the video. Essentially, there is a long list of songs, along with associated URLs and other information. Your manager has some basic functionality in mind, such as the ability to add and remove songs, as well as create playlists and show the videos. The application must run fast, and be updated with new features over time. Maintenance is key!
NOTE: For this project, we strongly suggest keeping a Notepad or MS Word document handy, containing the names of a few songs and associated video URLs.
Week 4: Using arrays to store song data
Objectives
1. Create individual one-dimensional arrays for each feature of a song
2. Edit the “Find Song” capability to display all of the data associated with a song.
3. Allow the user to click on an item in the song list ListBox, and display the array information for the selected item.
Introduction
Currently, when you enter a new song, you lose the associated artist, genre, and other data because you are not storing it anywhere. This can be resolved with arrays. This week you will create an array for the title, another for the artist, etc. As you know, when you declare an array, you need to know how many items will be in the array. “In real life” you would most likely use Lists instead, but that is a topic for later. For the purposes of this project, set a maximum array size of five songs.
Steps
1. Declare arrays of titles, artists, genres, years, and URLs. These will all be arrays of strings, with the exception of the year (integer). Because you want these arrays to be used by all of the methods in the form, they should be declared inside the partial class mainForm : Form area. Here is an example of two of the arrays, each with five elements in them (i.e., five songs). You will need to add arrays for genre, year, and url as well. All arrays are strings except year which will be an int:
int[] yearArray = new int[5];
Directly below the array initialization, include a song count variable as a counter. :
int songCount=0;
2. Edit the AddButton_Click event handler to:
a. Increment the songCount counter (which you declared and initialized to 0 just under the declarations for the arrays) when a song is successfully added.
b. Insert the new song data at the array positions indicated by the songCount. Remember, C# arrays indices start at 0, not 1!
c. Make sure, BEFORE you try adding anything to an array, that your songCount is not higher than the number of spaces in the array! If it is, then pop up a Messagebox stating that the user has reached their five-song limit.
d. NOTE: the text in textboxes is immutable, which means that you have to store it in a variable before you can perform other operations.
3. Write a method called int GetSongIndex(string songTitle). This function assumes that the song is in the songList, and returns the index of the song. To obtain the index of the found song, use this:
songIndex = songList.Items.IndexOf(songTitle);
4. Edit the FindButton_Click event handler to:
a. Keep track of the index of the song that you found in the songList. To do this, declare an integer variable songIndex, which you initialize to 0. You will also need to declare a StringBuilder variable.
b. If the song is in the songList,
i. call GetSongIndex to obtain the index of the song
ii. display the song title, genre, etc. in the outputText textbox
such as the code below (finish the code below and include display in the outputText box)
5. Create a SongList_SelectedIndexChanged event handler for the songList ListBox by double-clicking on the songList control. This will get the index of the song that the user clicked on, and display its information in the outputText textbox. The code is very similar to what you just wrote for FindButton_Click.
a. To get the index of the selected item, call songList.SelectedIndex, like this:
songIndex = songList.SelectedIndex;
6. Add the Web View Control to your form. You may have to drag the Song List and Details boxes smaller to ensure the web browser fits on the page. In order to add the Web View control you will need to add a package. Right click on your project name in the solution explorer and choose Manage NuGet Packages
7. Click on Browse and type in WebView2 in the text box. Click on Microsft.Web.WebView2 and install it.
8. Open your toolbox and you should see WebView2 Windows Form control above the All Windows forms and Common Controls. Expand that menu
9. Add the WebView2 control to your form (you may need to drag your form larger). Then increase the size of the control. Name the control webViewDisplay. You must also specify a default source site in the properties window. For example http://www.microsoft.com
10. Open the code in Form.cs. Add the following statement at the top of the code with the rest of the using statements: using Microsoft.Web.WebView2.Core;
11. Add a “Play” button. Recall that clicking on an item in the songList places the song details into the outputText textbox. Add a small “Play” button (playButton) below the Web View
12. Double-click on the new “Play” button and fill in the code for the PlayButton_Click event handler. The code should:
a. Get the index of the selected song in your songList songIndex=songList.SelectedIndex;
b. Using the index of the selected song, obtain the URL for the selected song (urlArray[songIndex])
c. Send the URL to the Web View and play the video
webViewDisplay.CoreWebView2.Navigate(url);
13. When you run your video manager you should see the Microsoft site appear immediately. If you don’t, you may need to download the web view runtime from Microsoft: https://developer.microsoft.com/en-us/microsoft-edge/webview2/
Please note, youtube may have ads so that when you click play you may have to watch the ad first or skip past them. In addition, use the Share button to obtain the URL from youtube:
Add 5 songs, click on one of the songs in the song list and click Play. Take a screenshot or a video showing the song playing.
Optional On Your Own
Research file processing and store your song data in a file.
Deliverables Week 4
· Submit your screenshot and code in the project deliverable.
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
