Rolamix / cordova-plugin-playlist

🎶 A Cordova plugin for Android and iOS with native support for audio playlists, background support, and lock screen controls 🎶
MIT License
32 stars 33 forks source link

Plugin does not handle streaming errors gracefully #8

Open robinbanbury opened 6 years ago

robinbanbury commented 6 years ago

Expected Behaviour

When the HTTP request to stream a playlist track is rejected (i.e. the response is an HTTP 4xx client error), the playlist should handle this gracefully, by continuing on to the next track on the playlist (or the previous track, if the user was skipping backwards through the playlist)

Actual Behaviour

The lockscreen UI indicates that the next track is playing, but no music can be heard. It is possible to work around the issue by skipping back and forwards through the tracks, which can cause the music to start playing again.

Reproduce Scenario (including but not limited to)

iOS with Ionic, streaming tracks from SoundCloud using stream URLs

Steps to Reproduce

Create a playlist with at least two valid streaming tracks. In between the two valid tracks, have another streaming track with URL https://api.soundcloud.com/tracks/274436003/stream?client_id=abcdefg - using an invalid SoundCloud key as shown here will cause an HTTP 401 error, which should be enough to reproduce the error.

Play the first track, and skip forward, or wait for the first track to end. The invalid track will be skipped over, and the lockscreen controls will display track information and playback information suggesting the next valid track is playing, when in fact no music is being played by the device.

Platform and Version

iOS 11.4

Cordova CLI version and cordova platform version

Cordova CLI version 7.1.0

Sample Code that illustrates the problem

  var testUrls = [
    'https://api.soundcloud.com/tracks/274436003/stream?client_id=XXXXXXXXXXXXXXXX',
    'https://api.soundcloud.com/tracks/141418479/stream?client_id=XXXXXXXXXXXXXXXX', // BAD
    'https://api.soundcloud.com/tracks/274436002/stream?client_id=XXXXXXXXXXXXXXXX',
  ];

  var testImgs = [
    'https://i1.sndcdn.com/artworks-000192365267-77o515-large.jpg',
    'https://i1.sndcdn.com/artworks-000192365267-77o515-large.jpg',
    'https://i1.sndcdn.com/artworks-000192365293-cym5e2-large.jpg',
  ];

  this.cdvAudioPlayer.setOptions({ verbose: true, resetStreamOnPause: true }).then(() => {
    this.cdvAudioPlayer.setPlaylistItems([
      // Intersperse good tracks with failures
      { trackId: '12345', assetUrl: testUrls[0], albumArt: testImgs[0], artist: 'Mount Nakara', album: 'Test Files', title: 'Test 1', isStream: true },
      { trackId: 'BAD45', assetUrl: testUrls[1], albumArt: testImgs[1], artist: 'Bad Artist 0', album: 'Invented', title: 'Invent track', isStream: true },
      { trackId: '678900', assetUrl: testUrls[2], albumArt: testImgs[2], artist: 'Mount Nakara', album: 'Test Files', title: 'Test 2', isStream: true },
    ])
    .then(() => {
      this.cdvAudioPlayer.play();
    }).catch((err) => console.log('YourService, cdvAudioPlayer setPlaylistItems error: ', err));
  }).catch((err) => console.log('YourService, cdvAudioPlayer init error: ', err));

Logs taken while reproducing problem

2018-07-09 07:36:06.600152+0100 ionic2-soundcloud[844:177701] Apache Cordova native platform version 4.5.3 is starting.
2018-07-09 07:36:06.600781+0100 ionic2-soundcloud[844:177701] Multi-tasking -> Device: YES, App: YES
2018-07-09 07:36:06.613311+0100 ionic2-soundcloud[844:177701] CDVWKWebViewEngine: trying to inject XHR polyfill
2018-07-09 07:36:06.659921+0100 ionic2-soundcloud[844:177701] CDVWKWebViewEngine will reload WKWebView if required on resume
2018-07-09 07:36:06.660124+0100 ionic2-soundcloud[844:177701] Using Ionic WKWebView
2018-07-09 07:36:06.660696+0100 ionic2-soundcloud[844:177701] [CDVTimer][console] 0.073910ms
2018-07-09 07:36:06.660915+0100 ionic2-soundcloud[844:177701] [CDVTimer][handleopenurl] 0.061035ms
2018-07-09 07:36:06.662662+0100 ionic2-soundcloud[844:177701] [CDVTimer][intentandnavigationfilter] 1.669049ms
2018-07-09 07:36:06.662885+0100 ionic2-soundcloud[844:177701] [CDVTimer][gesturehandler] 0.083923ms
2018-07-09 07:36:06.663615+0100 ionic2-soundcloud[844:177701] [CDVTimer][keyboard] 0.608087ms
2018-07-09 07:36:06.692812+0100 ionic2-soundcloud[844:177701] [CDVTimer][splashscreen] 29.049039ms
2018-07-09 07:36:06.730552+0100 ionic2-soundcloud[844:177701] OPTIONS are 0x2c
2018-07-09 07:36:06.878470+0100 ionic2-soundcloud[844:177701] [CDVTimer][rmxaudioplayer] 185.461998ms
2018-07-09 07:36:06.878547+0100 ionic2-soundcloud[844:177701] [CDVTimer][TotalPluginStartup] 218.008995ms
2018-07-09 07:36:07.308562+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer, queuePlayerCleared
2018-07-09 07:36:07.308627+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer, removeAllTracks, ==> RMXSTATUS_PLAYLIST_CLEARED
2018-07-09 07:36:08.433162+0100 ionic2-soundcloud[844:177701] Ionic Native: deviceready event fired after 676 ms
2018-07-09 07:36:08.433405+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.execute=initialize
2018-07-09 07:36:08.435761+0100 ionic2-soundcloud[844:177701] WARN: Native: tried calling StatusBar.styleDefault, but the StatusBar plugin is not installed.
2018-07-09 07:36:08.435932+0100 ionic2-soundcloud[844:177701] WARN: Install the StatusBar plugin: 'ionic cordova plugin add cordova-plugin-statusbar'
2018-07-09 07:36:08.444792+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:08.446680+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.execute=setOptions, {
    resetStreamOnPause = 1;
    verbose = 1;
}
2018-07-09 07:36:08.447181+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.execute=setOptions, {
    resetStreamOnPause = 1;
    verbose = 1;
}
2018-07-09 07:36:08.459700+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.execute=setPlaylistItems, {
}, (
        {
        album = "Test Files";
        albumArt = "https://i1.sndcdn.com/artworks-000192365267-77o515-large.jpg";
        artist = "Mount Nakara";
        assetUrl = "https://api.soundcloud.com/tracks/274436003/stream?client_id=XXXXXXXXXXXXXXXX";
        isStream = 1;
        title = "Test 1";
        trackId = 12345;
    },
        {
        album = Invented;
        albumArt = "https://i1.sndcdn.com/artworks-000192365267-77o515-large.jpg";
        artist = "Bad Artist 0";
        assetUrl = "https://api.soundcloud.com/tracks/141418479/stream?client_id=XXXXXXXXXXXXXXXX";
        isStream = 1;
        title = "Invent track";
        trackId = BAD45;
    },
        {
        album = "Test Files";
        albumArt = "https://i1.sndcdn.com/artworks-000192365293-cym5e2-large.jpg";
        artist = "Mount Nakara";
        assetUrl = "https://api.soundcloud.com/tracks/274436002/stream?client_id=XXXXXXXXXXXXXXXX";
        isStream = 1;
        title = "Test 2";
        trackId = 678900;
    }
)
2018-07-09 07:36:08.472993+0100 ionic2-soundcloud[844:177808] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    "r_Attributes" = 1;
    sync = syna;
}
2018-07-09 07:36:08.477733+0100 ionic2-soundcloud[844:177808] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    "r_Attributes" = 1;
    sync = syna;
}
2018-07-09 07:36:08.481080+0100 ionic2-soundcloud[844:177808] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    "r_Attributes" = 1;
    sync = syna;
}
2018-07-09 07:36:08.486554+0100 ionic2-soundcloud[844:177808] Queue changed current item to: {
    album = "Test Files";
    albumArt = "https://i1.sndcdn.com/artworks-000192365267-77o515-large.jpg";
    artist = "Mount Nakara";
    assetUrl = "https://api.soundcloud.com/tracks/274436003/stream?client_id=XXXXXXXXXXXXXXXX";
    isStream = 1;
    title = "Test 1";
    trackId = 12345;
}
2018-07-09 07:36:08.487206+0100 ionic2-soundcloud[844:177808] New item ID: 12345
2018-07-09 07:36:08.487256+0100 ionic2-soundcloud[844:177808] Queue is at end: NO
2018-07-09 07:36:08.493986+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Track Added(110) [12345]:  [object Object]
2018-07-09 07:36:08.494171+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:08.511800+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Loading(10) [12345]:
2018-07-09 07:36:08.512070+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:08.512270+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Track Added(110) [BAD45]:  [object Object]
2018-07-09 07:36:08.512401+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:08.512482+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Loading(10) [BAD45]:
2018-07-09 07:36:08.512550+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:08.512611+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Track Added(110) [678900]:  [object Object]
2018-07-09 07:36:08.513267+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:08.513558+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Loading(10) [678900]:
2018-07-09 07:36:08.514840+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:08.520177+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Track Changed(100) [12345]:  [object Object]
2018-07-09 07:36:08.520359+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:08.544934+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.execute=play
2018-07-09 07:36:08.548627+0100 ionic2-soundcloud[844:177701] Playback rate changed: 1.000000, is playing: 1
2018-07-09 07:36:08.626764+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Playing(30) [12345]:  [object Object]
2018-07-09 07:36:08.626964+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:11.744435+0100 ionic2-soundcloud[844:177701] The track duration was changed [678900]: 347.585297
2018-07-09 07:36:11.746930+0100 ionic2-soundcloud[844:177701] The track duration was changed [12345]: 275.539581
2018-07-09 07:36:11.798458+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Duration Changed(55) [678900]:  [object Object]
2018-07-09 07:36:11.798589+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:11.798657+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Duration Changed(55) [12345]:  [object Object]
2018-07-09 07:36:11.798719+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:11.823767+0100 ionic2-soundcloud[844:177701]  . . . 0.00000 -> 0.99265 (0.4 %) [12345]
2018-07-09 07:36:11.824301+0100 ionic2-soundcloud[844:177701] PlayerItem status changed to AVPlayerItemStatusReadyToPlay [12345]
2018-07-09 07:36:11.824847+0100 ionic2-soundcloud[844:177701] AVPlayerItemStatusFailed: Error playing audio track: Error playing audio track: (null)
2018-07-09 07:36:11.828996+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Buffering(25) [12345]:  [object Object]
2018-07-09 07:36:11.829150+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:11.829295+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: CanPlay(11) [12345]:  [object Object]
2018-07-09 07:36:11.829398+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:11.829487+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Error(5) [BAD45]:  [object Object]
2018-07-09 07:36:11.829603+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:12.147257+0100 ionic2-soundcloud[844:177701] playbackDuration ==> 0
2018-07-09 07:36:12.147333+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyElapsedPlaybackTime ==> 0
2018-07-09 07:36:12.147382+0100 ionic2-soundcloud[844:177701] title ==> Test 1
2018-07-09 07:36:12.147411+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyPlaybackRate ==> 1
2018-07-09 07:36:12.147439+0100 ionic2-soundcloud[844:177701] albumTitle ==> Test Files
2018-07-09 07:36:12.147464+0100 ionic2-soundcloud[844:177701] artist ==> Mount Nakara
2018-07-09 07:36:12.148675+0100 ionic2-soundcloud[844:177701] playbackDuration ==> 275.5396
2018-07-09 07:36:12.148805+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyElapsedPlaybackTime ==> -0.02937902
2018-07-09 07:36:12.148891+0100 ionic2-soundcloud[844:177701] title ==> Test 1
2018-07-09 07:36:12.148936+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyPlaybackRate ==> 1
2018-07-09 07:36:12.148980+0100 ionic2-soundcloud[844:177701] albumTitle ==> Test Files
2018-07-09 07:36:12.149023+0100 ionic2-soundcloud[844:177701] artist ==> Mount Nakara
2018-07-09 07:36:12.160975+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Playback Position Changed(40) [12345]:  [object Object]
2018-07-09 07:36:12.161114+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:12.161204+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Playback Position Changed(40) [12345]:  [object Object]
2018-07-09 07:36:12.161289+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:12.481170+0100 ionic2-soundcloud[844:177701]  . . . 0.00000 -> 15.25551 (5.5 %) [12345]
2018-07-09 07:36:12.484235+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Buffering(25) [12345]:  [object Object]
2018-07-09 07:36:12.484930+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:13.038974+0100 ionic2-soundcloud[844:177701]  . . . 0.00000 -> 146.31184 (53.1 %) [12345]
2018-07-09 07:36:13.049326+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Buffering(25) [12345]:  [object Object]
2018-07-09 07:36:13.049563+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:13.177944+0100 ionic2-soundcloud[844:177701] playbackDuration ==> 275.5396
2018-07-09 07:36:13.178252+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyElapsedPlaybackTime ==> -0.02780106
2018-07-09 07:36:13.178860+0100 ionic2-soundcloud[844:177701] title ==> Test 1
2018-07-09 07:36:13.179314+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyPlaybackRate ==> 1
2018-07-09 07:36:13.179567+0100 ionic2-soundcloud[844:177701] albumTitle ==> Test Files
2018-07-09 07:36:13.179819+0100 ionic2-soundcloud[844:177701] artist ==> Mount Nakara
2018-07-09 07:36:13.189475+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Playback Position Changed(40) [12345]:  [object Object]
2018-07-09 07:36:13.189811+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:13.621536+0100 ionic2-soundcloud[844:177701]  . . . 0.00000 -> 275.53958 (100.0 %) [12345]
2018-07-09 07:36:13.629885+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Buffering(25) [12345]:  [object Object]
2018-07-09 07:36:13.630295+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:13.630737+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Loaded(15) [12345]:  [object Object]
2018-07-09 07:36:13.631213+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:14.178201+0100 ionic2-soundcloud[844:177701] playbackDuration ==> 275.5396
2018-07-09 07:36:14.178478+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyElapsedPlaybackTime ==> 1.003164
2018-07-09 07:36:14.178775+0100 ionic2-soundcloud[844:177701] title ==> Test 1
2018-07-09 07:36:14.178944+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyPlaybackRate ==> 1
2018-07-09 07:36:14.179092+0100 ionic2-soundcloud[844:177701] albumTitle ==> Test Files
2018-07-09 07:36:14.179312+0100 ionic2-soundcloud[844:177701] artist ==> Mount Nakara
2018-07-09 07:36:14.208385+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Playback Position Changed(40) [12345]:  [object Object]
2018-07-09 07:36:14.209032+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:15.177759+0100 ionic2-soundcloud[844:177701] playbackDuration ==> 275.5396
2018-07-09 07:36:15.177831+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyElapsedPlaybackTime ==> 2.002413
2018-07-09 07:36:15.177878+0100 ionic2-soundcloud[844:177701] title ==> Test 1
2018-07-09 07:36:15.177908+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyPlaybackRate ==> 1
2018-07-09 07:36:15.177930+0100 ionic2-soundcloud[844:177701] albumTitle ==> Test Files
2018-07-09 07:36:15.177951+0100 ionic2-soundcloud[844:177701] artist ==> Mount Nakara
2018-07-09 07:36:15.353481+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Playback Position Changed(40) [12345]:  [object Object]
2018-07-09 07:36:15.360951+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:16.177240+0100 ionic2-soundcloud[844:177701] playbackDuration ==> 275.5396
2018-07-09 07:36:16.177485+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyElapsedPlaybackTime ==> 3.001105
2018-07-09 07:36:16.177843+0100 ionic2-soundcloud[844:177701] title ==> Test 1
2018-07-09 07:36:16.177874+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyPlaybackRate ==> 1
2018-07-09 07:36:16.177897+0100 ionic2-soundcloud[844:177701] albumTitle ==> Test Files
2018-07-09 07:36:16.177938+0100 ionic2-soundcloud[844:177701] artist ==> Mount Nakara
2018-07-09 07:36:16.346792+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Playback Position Changed(40) [12345]:  [object Object]
2018-07-09 07:36:16.351521+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:16.843774+0100 ionic2-soundcloud[844:177701] Queue changed current item to: {
    album = Invented;
    albumArt = "https://i1.sndcdn.com/artworks-000192365267-77o515-large.jpg";
    artist = "Bad Artist 0";
    assetUrl = "https://api.soundcloud.com/tracks/141418479/stream?client_id=XXXXXXXXXXXXXXXX";
    isStream = 1;
    title = "Invent track";
    trackId = BAD45;
}
2018-07-09 07:36:16.843855+0100 ionic2-soundcloud[844:177701] New item ID: BAD45
2018-07-09 07:36:16.843889+0100 ionic2-soundcloud[844:177701] Queue is at end: NO
2018-07-09 07:36:16.843941+0100 ionic2-soundcloud[844:177701] playbackDuration ==> 275.5396
2018-07-09 07:36:16.843970+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyElapsedPlaybackTime ==> 4.001124
2018-07-09 07:36:16.845380+0100 ionic2-soundcloud[844:177701] title ==> Test 1
2018-07-09 07:36:16.845634+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyPlaybackRate ==> 1
2018-07-09 07:36:16.845682+0100 ionic2-soundcloud[844:177701] albumTitle ==> Test Files
2018-07-09 07:36:16.845727+0100 ionic2-soundcloud[844:177701] artist ==> Mount Nakara
2018-07-09 07:36:16.846518+0100 ionic2-soundcloud[844:177701] music-controls-next
2018-07-09 07:36:16.851723+0100 ionic2-soundcloud[844:177701] playbackDuration ==> 0
2018-07-09 07:36:16.851825+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyElapsedPlaybackTime ==> 0
2018-07-09 07:36:16.851871+0100 ionic2-soundcloud[844:177701] title ==> Invent track
2018-07-09 07:36:16.851917+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyPlaybackRate ==> 1
2018-07-09 07:36:16.851975+0100 ionic2-soundcloud[844:177701] albumTitle ==> Invented
2018-07-09 07:36:16.852020+0100 ionic2-soundcloud[844:177701] artist ==> Bad Artist 0
2018-07-09 07:36:16.965064+0100 ionic2-soundcloud[844:177701] Queue changed current item to: {
    album = "Test Files";
    albumArt = "https://i1.sndcdn.com/artworks-000192365293-cym5e2-large.jpg";
    artist = "Mount Nakara";
    assetUrl = "https://api.soundcloud.com/tracks/274436002/stream?client_id=XXXXXXXXXXXXXXXX";
    isStream = 1;
    title = "Test 2";
    trackId = 678900;
}
2018-07-09 07:36:16.965149+0100 ionic2-soundcloud[844:177701] New item ID: 678900
2018-07-09 07:36:16.965181+0100 ionic2-soundcloud[844:177701] Queue is at end: YES
2018-07-09 07:36:16.965223+0100 ionic2-soundcloud[844:177701] playbackDuration ==> 0
2018-07-09 07:36:16.965251+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyElapsedPlaybackTime ==> 0
2018-07-09 07:36:16.965278+0100 ionic2-soundcloud[844:177701] title ==> Invent track
2018-07-09 07:36:16.965305+0100 ionic2-soundcloud[844:177701] MPNowPlayingInfoPropertyPlaybackRate ==> 1
2018-07-09 07:36:16.967440+0100 ionic2-soundcloud[844:177701] albumTitle ==> Invented
2018-07-09 07:36:16.967526+0100 ionic2-soundcloud[844:177701] artist ==> Bad Artist 0
2018-07-09 07:36:17.083554+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Track Changed(100) [BAD45]:  [object Object]
2018-07-09 07:36:17.090329+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:17.091250+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Skip Forward(90) [BAD45]:  [object Object]
2018-07-09 07:36:17.091916+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
2018-07-09 07:36:17.092612+0100 ionic2-soundcloud[844:177701] RmxAudioPlayer.onStatus: Playback Position Changed(40) [BAD45]:  [object Object]
2018-07-09 07:36:17.093036+0100 ionic2-soundcloud[844:177701] YourService: Got RmxAudioPlayer onStatus:  [object Object]
codinronan commented 6 years ago

Hi @robincsmith yep I struggled with this one. Seems the errors aren't always surfaced. Will take another crack at it.

robinbanbury commented 6 years ago

Awesome, thanks! The 'BAD' url above should generate a 401 or 403 error, which should be enough to reproduce the problem (or, you can use any SoundCloud URL without specifying a valid client_id).

I guess if the streaming URL does result in a 4xx error, it would be good to catch that and make sure the next track starts playback without any issues. Other than that, the error handling seems good - I'm not too familiar with Objective-C but it seems like the 'bad track' gets removed from the playlist after the user first tries to stream it?

robinbanbury commented 6 years ago

@codinronan I've had the chance to play with this a bit in an application now, and it seems the player automatically tries to 'skip' past the offending track and play the next one. Sometimes this works really well, and the next / previous track starts playing, but other times it doesn't work so well - the new track can be muted, or you can't skip back past a certain point in the playlist.

Would it be possible to throw some kind of status error up to the application, and let it decide how to handle this? Or might this interrupt the continuous lockscreen / background playback?

Even if it's better to handle the error in this plugin, it would be really useful to get an error status thrown up to the application somehow, so that appropriate action can be taken (greying out the track in the UI / displaying an error message to the user, for example)

robinbanbury commented 5 years ago

I think the best way to handle this is by catching RmxAudioStatusMessage.RMXSTATUS_ERROR status messages with code RmxAudioErrorType.RMXERR_DECODE when adding tracks to the playlist