Guest User

Untitled

a guest
Mar 23rd, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.41 KB | None | 0 0
  1. Imports System.IO
  2. Imports System.Net
  3. Imports System.Threading
  4.  
  5. Public Class OneMedia
  6. Dim GotoYTMP3 As System.Threading.Thread
  7. 'Dim NavigateYTMP3 As System.Threading.Thread
  8. 'Dim DownloadYTMP3 As System.Threading.Thread
  9. Private Sub SaveFunction()
  10. Dim w As New IO.StreamWriter("Stations.dll")
  11. Dim i As Integer
  12. For i = 0 To ListBox1.Items.Count - 1
  13. w.WriteLine(ListBox1.Items.Item(i))
  14. Next
  15. w.Close()
  16. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  17. Dim wr As New IO.StreamWriter("NameStations.dll")
  18. Dim ii As Integer
  19. For ii = 0 To ListBox2.Items.Count - 1
  20. wr.WriteLine(ListBox2.Items.Item(ii))
  21. Next
  22. wr.Close()
  23. End Sub
  24. Function Between(ByVal org As String, ByVal first As String, ByVal last As String) As String
  25. On Error Resume Next
  26. Dim startloc As Integer = org.IndexOf(first, 0)
  27. Dim endloc As Integer = org.IndexOf(last, startloc + first.Length)
  28. startloc = startloc + first.Length
  29. endloc = endloc - startloc
  30. Return org.Substring(startloc, endloc)
  31. End Function
  32. Private Sub DLLLoad()
  33. If Not File.Exists("Stations.dll") Then
  34. File.Create("Stations.dll")
  35. Else
  36. Try
  37. Dim Station = "Stations.dll"
  38. Dim dataloader As New System.IO.StreamReader(Station)
  39. While (dataloader.Peek() > -1)
  40. ListBox1.Items.Add(dataloader.ReadLine)
  41. End While
  42. dataloader.Close()
  43. Catch ex As Exception
  44. MsgBox("Could not load Your Stations: " + ex.Message)
  45. End Try
  46. End If
  47.  
  48. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  49. If Not File.Exists("NameStations.dll") Then
  50. File.Create("NameStations.dll")
  51. Else
  52. Try
  53. Dim NameStation = "NameStations.dll"
  54. Dim dataloader As New System.IO.StreamReader(NameStation)
  55. While (dataloader.Peek() > -1)
  56. ListBox2.Items.Add(dataloader.ReadLine)
  57. End While
  58. dataloader.Close()
  59. Catch ex As Exception
  60. MsgBox("Could not load name of your Stations: " + ex.Message)
  61. End Try
  62. End If
  63. End Sub
  64. Public Sub CheckForUpdates()
  65. Dim Answer
  66. Try
  67. Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://dl.dropbox.com/u/14318663/One%20Media/fradioupdate.txt")
  68. Dim response As System.Net.HttpWebResponse = request.GetResponse()
  69. Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
  70.  
  71. Dim newestversion As String = sr.ReadToEnd()
  72. Dim currentversion As String = Application.ProductVersion
  73. If newestversion.Contains(currentversion) Then
  74.  
  75. Else
  76. Console.Beep()
  77. Answer = MsgBox("There is a new update for OneMedia, would you like to download it?", vbYesNo)
  78. If Answer = vbYes Then
  79. If File.Exists("Updater.exe") Then
  80. Try
  81. Process.Start("Updater.exe")
  82. Application.Exit()
  83. Catch ex As Exception
  84. MsgBox("Updater was not found in the folder please place it in the same folder as OneMedia")
  85. End Try
  86. End If
  87. End If
  88. End If
  89. Catch ex As Exception
  90. MsgBox("No internet connection :( " + ex.Message, MsgBoxStyle.Exclamation, "Connection not found")
  91. End Try
  92. End Sub
  93. Private Function IsConnectionAvailable() As Boolean
  94. 'Call url "google.com"
  95. Dim url As New System.Uri("http://www.google.com/")
  96. 'Request for request
  97. Dim req As System.Net.WebRequest
  98. req = System.Net.WebRequest.Create(url)
  99. Dim resp As System.Net.WebResponse
  100. Try
  101. resp = req.GetResponse()
  102. resp.Close()
  103. req = Nothing
  104. Return True
  105. Catch ex As Exception
  106. MsgBox("Detected: No Internet connection, please connect to the internet", MsgBoxStyle.Exclamation, "Connection not found")
  107. req = Nothing
  108. Return False
  109. End Try
  110. End Function
  111. Private Sub OneMedia_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  112. WebBrowser2.Navigate("http://www.youtube-mp3.org/")
  113. CheckForUpdates()
  114. IsConnectionAvailable() 'Connect to google.com to check if internet is working
  115. DLLLoad()
  116. End Sub
  117. Private Sub DownloadYtoMP3()
  118. Try
  119. Dim s As String = WebBrowser2.Document.GetElementById("dl_link").InnerHtml
  120. 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>", "")
  121. TextBox7.Text = redirect
  122. WebBrowser2.Navigate(redirect)
  123. MsgBox("Thank you for using OneMedia", MsgBoxStyle.Information, "Thank you")
  124. Catch ex As Exception
  125. MsgBox("Sorry this is not a youtube video, please youtube link: " + ex.Message, MsgBoxStyle.Critical, "Link Error")
  126. 'WebBrowser2.Navigate("http://www.youtube-mp3.org/")
  127. End Try
  128. End Sub
  129. Private Sub Navigate()
  130. WebBrowser2.Document.GetElementById("youtube-url").SetAttribute("Value", TextBox1.Text)
  131. WebBrowser2.Document.GetElementById("submit").InvokeMember("Click")
  132. End Sub
  133. Private Sub Button10_Click(sender As System.Object, e As System.EventArgs) Handles Button10.Click
  134. If TextBox1.Text = "" Then
  135. MsgBox("Can't continue there is no youtube link")
  136. Else
  137. Dim Yes As String
  138. Try
  139. Navigate()
  140. Yes = MsgBox("Link Submitted would you like to download?", vbYesNo, "Download")
  141. If Yes = vbYes Then
  142. DownloadYtoMP3()
  143. End If
  144. Catch ex As Exception
  145. MsgBox("Could not submit your link for conversion: " + ex.Message, MsgBoxStyle.Exclamation, "Link Error")
  146. End Try
  147. End If
  148. End Sub
  149.  
  150. Private Sub TrackBar1_Scroll(sender As System.Object, e As System.EventArgs) Handles TrackBar1.Scroll
  151. AxWindowsMediaPlayer1.settings.volume = TrackBar1.Value
  152. End Sub
  153.  
  154. Private Sub ListBox1_Click(sender As Object, e As System.EventArgs) Handles ListBox1.Click
  155. Try
  156. If ListBox1.SelectedItem = "" Then
  157. MsgBox("Please select a station", MsgBoxStyle.Information, "Select a Station")
  158. Else
  159. AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
  160. ComboBox1.SelectedText = ""
  161. End If
  162. Catch ex As Exception
  163. MsgBox("Please select the radio station you want to play, then press play")
  164. End Try
  165. End Sub
  166.  
  167. Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
  168. If ListBox1.SelectedItem = "" Then
  169. ListBox1.Items.Remove(ListBox1.SelectedItem)
  170. End If
  171. End Sub
  172.  
  173. Private Sub ListBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
  174. If ListBox2.SelectedItem = "" Then
  175. ListBox2.Items.Remove(ListBox2.SelectedItem)
  176. End If
  177. End Sub
  178.  
  179. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  180. AxWindowsMediaPlayer1.Ctlcontrols.play()
  181. End Sub
  182.  
  183. Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
  184. AxWindowsMediaPlayer1.Ctlcontrols.pause()
  185. End Sub
  186.  
  187. Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
  188. TrackBar1.Value = "0"
  189. AxWindowsMediaPlayer1.settings.volume = "0"
  190. End Sub
  191.  
  192. Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
  193. TrackBar1.Value = "50"
  194. AxWindowsMediaPlayer1.settings.volume = "50"
  195. End Sub
  196.  
  197. Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
  198. WebBrowser1.Navigate("http://www.youtube.com/results?search_type=&search_query=" + TxtYoutube.Text + "&aq=f")
  199. TxtYoutube.Clear()
  200. End Sub
  201. Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
  202. Private Sub WebBrowser1_Navigated(sender As Object, e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
  203. TxtWebUrl.Text = WebBrowser1.Url.ToString
  204. End Sub
  205.  
  206. Private Sub TxtYoutube_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TxtYoutube.KeyDown
  207. If GetAsyncKeyState(13) Then
  208. WebBrowser1.Navigate("http://www.youtube.com/results?search_type=&search_query=" + TxtYoutube.Text + "&aq=f")
  209. End If
  210. End Sub
  211.  
  212. Private Sub PlayToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PlayToolStripMenuItem.Click
  213. AxWindowsMediaPlayer1.Ctlcontrols.play()
  214. End Sub
  215.  
  216. Private Sub PauseToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PauseToolStripMenuItem.Click
  217. AxWindowsMediaPlayer1.Ctlcontrols.pause()
  218. End Sub
  219.  
  220. Private Sub FullScreenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles FullScreenToolStripMenuItem.Click
  221. Try
  222. AxWindowsMediaPlayer1.fullScreen = True
  223. Catch ex As Exception
  224. MsgBox("You must be playing something to go into fullscreen", MsgBoxStyle.Information, "NO!")
  225. End Try
  226. End Sub
  227.  
  228. Private Sub RepeatDisableToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RepeatDisableToolStripMenuItem.Click
  229. AxWindowsMediaPlayer1.settings.setMode("loop", False)
  230. MsgBox("Repeat Disabled!", MsgBoxStyle.Information, "Loop")
  231. End Sub
  232.  
  233. Private Sub RepeatEnableToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RepeatEnableToolStripMenuItem.Click
  234. AxWindowsMediaPlayer1.settings.setMode("loop", True)
  235. MsgBox("Repeat Enabled!", MsgBoxStyle.Information, "Loop")
  236. End Sub
  237.  
  238. Private Sub UnmuteToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles UnmuteToolStripMenuItem.Click
  239. TrackBar1.Value = "50"
  240. AxWindowsMediaPlayer1.settings.volume = "50"
  241. End Sub
  242.  
  243. Private Sub MuteToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles MuteToolStripMenuItem.Click
  244. TrackBar1.Value = "0"
  245. AxWindowsMediaPlayer1.settings.volume = "0"
  246. End Sub
  247.  
  248. Private Sub MyMusicToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles MyMusicToolStripMenuItem.Click
  249. ComboBox1.SelectedText = ""
  250. Dim openFileDialog1 As New OpenFileDialog()
  251. openFileDialog1.Filter = ""
  252. openFileDialog1.Title = "Select a music file"
  253. If openFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
  254. AxWindowsMediaPlayer1.URL = (openFileDialog1.FileName)
  255. End If
  256. End Sub
  257.  
  258. Private Sub SaveToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SaveToolStripMenuItem.Click
  259. SaveFunction()
  260. End Sub
  261.  
  262. Private Sub ClearToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ClearToolStripMenuItem.Click
  263. ListBox1.Items.Clear()
  264. ListBox2.Items.Clear()
  265. End Sub
  266.  
  267. Private Sub RemoveToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RemoveToolStripMenuItem.Click
  268. ListBox1.Items.Remove(ListBox1.SelectedItem)
  269. ListBox2.Items.Remove(ListBox2.SelectedItem)
  270. End Sub
  271.  
  272. Private Sub AddToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles AddToolStripMenuItem.Click
  273. TextBox3.Text = InputBox("Enter the URL for this station", "Stations URLs")
  274. TextBox2.Text = InputBox("Enter the nickname for this station", "Stations Nicknames")
  275. ListBox2.Items.Add(TextBox2.Text)
  276. ListBox1.Items.Add(TextBox3.Text)
  277. End Sub
  278.  
  279. Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
  280. WebBrowser1.Navigate("http://www.listenonrepeat.com/watch/?v=" + TextBox4.Text)
  281. End Sub
  282.  
  283. Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click
  284. WebBrowser1.Navigate("null")
  285. End Sub
  286. Private Sub ToolStripMenuItem4_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripMenuItem4.Click
  287. SaveFunction()
  288. End Sub
  289.  
  290. Private Sub ToolStripMenuItem5_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripMenuItem5.Click
  291. ListBox1.Items.Clear()
  292. ListBox2.Items.Clear()
  293. End Sub
  294.  
  295. Private Sub ToolStripMenuItem3_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripMenuItem3.Click
  296. ListBox1.Items.Remove(ListBox1.SelectedItem)
  297. ListBox2.Items.Remove(ListBox2.SelectedItem)
  298. End Sub
  299.  
  300. Private Sub ToolStripMenuItem2_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripMenuItem2.Click
  301. TextBox3.Text = InputBox("Enter the URL for this station", "Stations URLs")
  302. TextBox2.Text = InputBox("Enter the nickname for this station", "Stations Nicknames")
  303. ListBox2.Items.Add(TextBox2.Text)
  304. ListBox1.Items.Add(TextBox3.Text)
  305. End Sub
  306.  
  307. Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
  308. If ComboBox1.SelectedItem = "ElectricFM" Then
  309. AxWindowsMediaPlayer1.URL = "http://servers.internet-radio.com/tools/playlistgenerator/?u=http://uk1.internet-radio.com:15614/listen.pls&t=.m3u"
  310. End If
  311. End Sub
  312.  
  313. Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
  314. Info.Show()
  315. End Sub
  316.  
  317. Private Sub Button13_Click(sender As System.Object, e As System.EventArgs) Handles Button13.Click
  318. WebBrowser1.GoBack()
  319. End Sub
  320.  
  321. Private Sub Button14_Click(sender As System.Object, e As System.EventArgs) Handles Button14.Click
  322. WebBrowser1.GoForward()
  323. End Sub
  324.  
  325. Private Sub Button9_Click(sender As System.Object, e As System.EventArgs) Handles Button9.Click
  326. WebBrowser2.Navigate("http://www.youtube-mp3.org/")
  327. End Sub
  328.  
  329. Private Sub Button11_Click(sender As System.Object, e As System.EventArgs) Handles Button11.Click
  330. AxShockwaveFlash1.Movie = "https://www.youtube.com/v/" + TextEmbed.Text
  331. End Sub
  332.  
  333. Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
  334. Try
  335. Me.LabelNowPlaying.Text = "Now Playing: " + AxWindowsMediaPlayer1.currentMedia.getItemInfo("Artist") + " " + AxWindowsMediaPlayer1.currentMedia.getItemInfo("Title")
  336. Catch ex As Exception
  337.  
  338. End Try
  339. End Sub
  340. End Class
Advertisement
Add Comment
Please, Sign In to add comment