Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Net
- Imports System.Threading
- Public Class OneMedia
- Dim GotoYTMP3 As System.Threading.Thread
- 'Dim NavigateYTMP3 As System.Threading.Thread
- 'Dim DownloadYTMP3 As System.Threading.Thread
- Private Sub SaveFunction()
- Dim w As New IO.StreamWriter("Stations.dll")
- Dim i As Integer
- For i = 0 To ListBox1.Items.Count - 1
- w.WriteLine(ListBox1.Items.Item(i))
- Next
- w.Close()
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- Dim wr As New IO.StreamWriter("NameStations.dll")
- Dim ii As Integer
- For ii = 0 To ListBox2.Items.Count - 1
- wr.WriteLine(ListBox2.Items.Item(ii))
- Next
- wr.Close()
- End Sub
- Function Between(ByVal org As String, ByVal first As String, ByVal last As String) As String
- On Error Resume Next
- Dim startloc As Integer = org.IndexOf(first, 0)
- Dim endloc As Integer = org.IndexOf(last, startloc + first.Length)
- startloc = startloc + first.Length
- endloc = endloc - startloc
- Return org.Substring(startloc, endloc)
- End Function
- Private Sub DLLLoad()
- If Not File.Exists("Stations.dll") Then
- File.Create("Stations.dll")
- Else
- Try
- Dim Station = "Stations.dll"
- Dim dataloader As New System.IO.StreamReader(Station)
- While (dataloader.Peek() > -1)
- ListBox1.Items.Add(dataloader.ReadLine)
- End While
- dataloader.Close()
- Catch ex As Exception
- MsgBox("Could not load Your Stations: " + ex.Message)
- End Try
- End If
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- If Not File.Exists("NameStations.dll") Then
- File.Create("NameStations.dll")
- Else
- Try
- Dim NameStation = "NameStations.dll"
- Dim dataloader As New System.IO.StreamReader(NameStation)
- While (dataloader.Peek() > -1)
- ListBox2.Items.Add(dataloader.ReadLine)
- End While
- dataloader.Close()
- Catch ex As Exception
- MsgBox("Could not load name of your Stations: " + ex.Message)
- End Try
- End If
- End Sub
- Public Sub CheckForUpdates()
- Dim Answer
- Try
- Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://dl.dropbox.com/u/14318663/One%20Media/fradioupdate.txt")
- Dim response As System.Net.HttpWebResponse = request.GetResponse()
- Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
- Dim newestversion As String = sr.ReadToEnd()
- Dim currentversion As String = Application.ProductVersion
- If newestversion.Contains(currentversion) Then
- Else
- Console.Beep()
- Answer = MsgBox("There is a new update for OneMedia, would you like to download it?", vbYesNo)
- If Answer = vbYes Then
- If File.Exists("Updater.exe") Then
- Try
- Process.Start("Updater.exe")
- Application.Exit()
- Catch ex As Exception
- MsgBox("Updater was not found in the folder please place it in the same folder as OneMedia")
- End Try
- End If
- End If
- End If
- Catch ex As Exception
- MsgBox("No internet connection :( " + ex.Message, MsgBoxStyle.Exclamation, "Connection not found")
- End Try
- End Sub
- Private Function IsConnectionAvailable() As Boolean
- 'Call url "google.com"
- Dim url As New System.Uri("http://www.google.com/")
- 'Request for request
- Dim req As System.Net.WebRequest
- req = System.Net.WebRequest.Create(url)
- Dim resp As System.Net.WebResponse
- Try
- resp = req.GetResponse()
- resp.Close()
- req = Nothing
- Return True
- Catch ex As Exception
- MsgBox("Detected: No Internet connection, please connect to the internet", MsgBoxStyle.Exclamation, "Connection not found")
- req = Nothing
- Return False
- End Try
- End Function
- Private Sub OneMedia_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- WebBrowser2.Navigate("http://www.youtube-mp3.org/")
- CheckForUpdates()
- IsConnectionAvailable() 'Connect to google.com to check if internet is working
- DLLLoad()
- End Sub
- Private Sub DownloadYtoMP3()
- Try
- Dim s As String = WebBrowser2.Document.GetElementById("dl_link").InnerHtml
- Dim redirect As String = s.Replace("<A href=""", "").Replace("""><B>Download</B><A> . <A onclick=""showLinkBox(); return false;"" href=""http://youtube-mp3.org/#"">Link This mp3</A>", "")
- TextBox7.Text = redirect
- WebBrowser2.Navigate(redirect)
- MsgBox("Thank you for using OneMedia", MsgBoxStyle.Information, "Thank you")
- Catch ex As Exception
- MsgBox("Sorry this is not a youtube video, please youtube link: " + ex.Message, MsgBoxStyle.Critical, "Link Error")
- 'WebBrowser2.Navigate("http://www.youtube-mp3.org/")
- End Try
- End Sub
- Private Sub Navigate()
- WebBrowser2.Document.GetElementById("youtube-url").SetAttribute("Value", TextBox1.Text)
- WebBrowser2.Document.GetElementById("submit").InvokeMember("Click")
- End Sub
- Private Sub Button10_Click(sender As System.Object, e As System.EventArgs) Handles Button10.Click
- If TextBox1.Text = "" Then
- MsgBox("Can't continue there is no youtube link")
- Else
- Dim Yes As String
- Try
- Navigate()
- Yes = MsgBox("Link Submitted would you like to download?", vbYesNo, "Download")
- If Yes = vbYes Then
- DownloadYtoMP3()
- End If
- Catch ex As Exception
- MsgBox("Could not submit your link for conversion: " + ex.Message, MsgBoxStyle.Exclamation, "Link Error")
- End Try
- End If
- End Sub
- Private Sub TrackBar1_Scroll(sender As System.Object, e As System.EventArgs) Handles TrackBar1.Scroll
- AxWindowsMediaPlayer1.settings.volume = TrackBar1.Value
- End Sub
- Private Sub ListBox1_Click(sender As Object, e As System.EventArgs) Handles ListBox1.Click
- Try
- If ListBox1.SelectedItem = "" Then
- MsgBox("Please select a station", MsgBoxStyle.Information, "Select a Station")
- Else
- AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
- ComboBox1.SelectedText = ""
- End If
- Catch ex As Exception
- MsgBox("Please select the radio station you want to play, then press play")
- End Try
- End Sub
- Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
- If ListBox1.SelectedItem = "" Then
- ListBox1.Items.Remove(ListBox1.SelectedItem)
- End If
- End Sub
- Private Sub ListBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
- If ListBox2.SelectedItem = "" Then
- ListBox2.Items.Remove(ListBox2.SelectedItem)
- End If
- End Sub
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- AxWindowsMediaPlayer1.Ctlcontrols.play()
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- AxWindowsMediaPlayer1.Ctlcontrols.pause()
- End Sub
- Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
- TrackBar1.Value = "0"
- AxWindowsMediaPlayer1.settings.volume = "0"
- End Sub
- Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
- TrackBar1.Value = "50"
- AxWindowsMediaPlayer1.settings.volume = "50"
- End Sub
- Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
- WebBrowser1.Navigate("http://www.youtube.com/results?search_type=&search_query=" + TxtYoutube.Text + "&aq=f")
- TxtYoutube.Clear()
- End Sub
- Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
- Private Sub WebBrowser1_Navigated(sender As Object, e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
- TxtWebUrl.Text = WebBrowser1.Url.ToString
- End Sub
- Private Sub TxtYoutube_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TxtYoutube.KeyDown
- If GetAsyncKeyState(13) Then
- WebBrowser1.Navigate("http://www.youtube.com/results?search_type=&search_query=" + TxtYoutube.Text + "&aq=f")
- End If
- End Sub
- Private Sub PlayToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PlayToolStripMenuItem.Click
- AxWindowsMediaPlayer1.Ctlcontrols.play()
- End Sub
- Private Sub PauseToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PauseToolStripMenuItem.Click
- AxWindowsMediaPlayer1.Ctlcontrols.pause()
- End Sub
- Private Sub FullScreenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles FullScreenToolStripMenuItem.Click
- Try
- AxWindowsMediaPlayer1.fullScreen = True
- Catch ex As Exception
- MsgBox("You must be playing something to go into fullscreen", MsgBoxStyle.Information, "NO!")
- End Try
- End Sub
- Private Sub RepeatDisableToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RepeatDisableToolStripMenuItem.Click
- AxWindowsMediaPlayer1.settings.setMode("loop", False)
- MsgBox("Repeat Disabled!", MsgBoxStyle.Information, "Loop")
- End Sub
- Private Sub RepeatEnableToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RepeatEnableToolStripMenuItem.Click
- AxWindowsMediaPlayer1.settings.setMode("loop", True)
- MsgBox("Repeat Enabled!", MsgBoxStyle.Information, "Loop")
- End Sub
- Private Sub UnmuteToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles UnmuteToolStripMenuItem.Click
- TrackBar1.Value = "50"
- AxWindowsMediaPlayer1.settings.volume = "50"
- End Sub
- Private Sub MuteToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles MuteToolStripMenuItem.Click
- TrackBar1.Value = "0"
- AxWindowsMediaPlayer1.settings.volume = "0"
- End Sub
- Private Sub MyMusicToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles MyMusicToolStripMenuItem.Click
- ComboBox1.SelectedText = ""
- Dim openFileDialog1 As New OpenFileDialog()
- openFileDialog1.Filter = ""
- openFileDialog1.Title = "Select a music file"
- If openFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
- AxWindowsMediaPlayer1.URL = (openFileDialog1.FileName)
- End If
- End Sub
- Private Sub SaveToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SaveToolStripMenuItem.Click
- SaveFunction()
- End Sub
- Private Sub ClearToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ClearToolStripMenuItem.Click
- ListBox1.Items.Clear()
- ListBox2.Items.Clear()
- End Sub
- Private Sub RemoveToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RemoveToolStripMenuItem.Click
- ListBox1.Items.Remove(ListBox1.SelectedItem)
- ListBox2.Items.Remove(ListBox2.SelectedItem)
- End Sub
- Private Sub AddToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles AddToolStripMenuItem.Click
- TextBox3.Text = InputBox("Enter the URL for this station", "Stations URLs")
- TextBox2.Text = InputBox("Enter the nickname for this station", "Stations Nicknames")
- ListBox2.Items.Add(TextBox2.Text)
- ListBox1.Items.Add(TextBox3.Text)
- End Sub
- Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
- WebBrowser1.Navigate("http://www.listenonrepeat.com/watch/?v=" + TextBox4.Text)
- End Sub
- Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click
- WebBrowser1.Navigate("null")
- End Sub
- Private Sub ToolStripMenuItem4_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripMenuItem4.Click
- SaveFunction()
- End Sub
- Private Sub ToolStripMenuItem5_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripMenuItem5.Click
- ListBox1.Items.Clear()
- ListBox2.Items.Clear()
- End Sub
- Private Sub ToolStripMenuItem3_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripMenuItem3.Click
- ListBox1.Items.Remove(ListBox1.SelectedItem)
- ListBox2.Items.Remove(ListBox2.SelectedItem)
- End Sub
- Private Sub ToolStripMenuItem2_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripMenuItem2.Click
- TextBox3.Text = InputBox("Enter the URL for this station", "Stations URLs")
- TextBox2.Text = InputBox("Enter the nickname for this station", "Stations Nicknames")
- ListBox2.Items.Add(TextBox2.Text)
- ListBox1.Items.Add(TextBox3.Text)
- End Sub
- Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
- If ComboBox1.SelectedItem = "ElectricFM" Then
- AxWindowsMediaPlayer1.URL = "http://servers.internet-radio.com/tools/playlistgenerator/?u=http://uk1.internet-radio.com:15614/listen.pls&t=.m3u"
- End If
- End Sub
- Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
- Info.Show()
- End Sub
- Private Sub Button13_Click(sender As System.Object, e As System.EventArgs) Handles Button13.Click
- WebBrowser1.GoBack()
- End Sub
- Private Sub Button14_Click(sender As System.Object, e As System.EventArgs) Handles Button14.Click
- WebBrowser1.GoForward()
- End Sub
- Private Sub Button9_Click(sender As System.Object, e As System.EventArgs) Handles Button9.Click
- WebBrowser2.Navigate("http://www.youtube-mp3.org/")
- End Sub
- Private Sub Button11_Click(sender As System.Object, e As System.EventArgs) Handles Button11.Click
- AxShockwaveFlash1.Movie = "https://www.youtube.com/v/" + TextEmbed.Text
- End Sub
- Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
- Try
- Me.LabelNowPlaying.Text = "Now Playing: " + AxWindowsMediaPlayer1.currentMedia.getItemInfo("Artist") + " " + AxWindowsMediaPlayer1.currentMedia.getItemInfo("Title")
- Catch ex As Exception
- End Try
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment