getmusicbee.com
Support => Developers' Area => MusicBee API => Topic started by: stax76 on February 28, 2017, 03:02:38 PM
-
Case NotificationType.TagsChanging
Try
Dim nowPlayingrating = CInt(mbApiInterface.NowPlaying_GetFileTag(MetaDataType.Rating))
If nowPlayingrating < 3 Then
Dim currentIndex = mbApiInterface.NowPlayingList_GetCurrentIndex()
Dim nextURL = mbApiInterface.NowPlayingList_GetListFileUrl(currentIndex + 1)
mbApiInterface.NowPlayingList_PlayNow(nextURL)
End If
Catch ex As Exception
End Try
I'm trying now for an hour to achieve something that seems very easy, I have keyboard shortcuts to rate the currently playing track, now when I rate it 0-2 I want to play the next track, my url for the next track is fine, what happens is playback freezes.
-
I also tried mbApiInterface.Player_PlayNextTrack() which freezes also, I enabled .NET 4.5 to use the Task API making it easy to sleep a seconds, this finally has worked.
Public Sub ReceiveNotification(sourceFileUrl As String, type As NotificationType)
Try
Select Case type
Case NotificationType.TagsChanging
Dim nowPlayingRating = CInt(mbApiInterface.NowPlaying_GetFileTag(MetaDataType.Rating))
If nowPlayingRating < 3 Then PlayNext()
End Select
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Async Sub PlayNext()
Await Tasks.Task.Run(Sub() Thread.Sleep(1000))
mbApiInterface.Player_PlayNextTrack()
End Sub
-
you could try to stop player before playing next track (without tasks and sleeping).
-
you could try to stop player before playing next track (without tasks and sleeping).
I tried it but it also don't work properly.
-
the NotificationType.TagsChanging and NotificationType.RatingChanging events only are messaged synchronously from the MB GUI thread.
If you do anything in the plugin that causes the API to invoke to the GUI thread then the plugin will block