{"action":"created","issue":{"url":"https://api.github.com/repos/leon/cordova-plugin-nowplaying/issues/4","repository_url":"https://api.github.com/repos/leon/cordova-plugin-nowplaying","labels_url":"https://api.github.com/repos/leon/cordova-plugin-nowplaying/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/leon/cordova-plugin-nowplaying/issues/4/comments","events_url":"https://api.github.com/repos/leon/cordova-plugin-nowplaying/issues/4/events","html_url":"https://github.com/leon/cordova-plugin-nowplaying/issues/4","id":189692306,"number":4,"title":"Timing progress not stoping on Pause","user":{"login":"SebDigital","id":5473849,"avatar_url":"https://avatars.githubusercontent.com/u/5473849?v=3","gravatar_id":"","url":"https://api.github.com/users/SebDigital","html_url":"https://github.com/SebDigital","followers_url":"https://api.github.com/users/SebDigital/followers","following_url":"https://api.github.com/users/SebDigital/following{/other_user}","gists_url":"https://api.github.com/users/SebDigital/gists{/gist_id}","starred_url":"https://api.github.com/users/SebDigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SebDigital/subscriptions","organizations_url":"https://api.github.com/users/SebDigital/orgs","repos_url":"https://api.github.com/users/SebDigital/repos","events_url":"https://api.github.com/users/SebDigital/events{/privacy}","received_events_url":"https://api.github.com/users/SebDigital/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-16T12:41:49Z","updated_at":"2016-11-16T13:08:35Z","closed_at":null,"body":"Hi,\r\n\r\nReally good job on the plugin, it is all working for me except than when I press pause, the time of the track doesn't pause..any idea?\r\n\r\nI am on IOS10 on iPhone5, tested on iPhone6 and same issue too\r\n\r\nThanks!\r\n\r\nSeb"},"comment":{"url":"https://api.github.com/repos/leon/cordova-plugin-nowplaying/issues/comments/260942083","html_url":"https://github.com/leon/cordova-plugin-nowplaying/issues/4#issuecomment-260942083","issue_url":"https://api.github.com/repos/leon/cordova-plugin-nowplaying/issues/4","id":260942083,"user":{"login":"leon","id":13211,"avatar_url":"https://avatars.githubusercontent.com/u/13211?v=3","gravatar_id":"","url":"https://api.github.com/users/leon","html_url":"https://github.com/leon","followers_url":"https://api.github.com/users/leon/followers","following_url":"https://api.github.com/users/leon/following{/other_user}","gists_url":"https://api.github.com/users/leon/gists{/gist_id}","starred_url":"https://api.github.com/users/leon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leon/subscriptions","organizations_url":"https://api.github.com/users/leon/orgs","repos_url":"https://api.github.com/users/leon/repos","events_url":"https://api.github.com/users/leon/events{/privacy}","received_events_url":"https://api.github.com/users/leon/received_events","type":"User","site_admin":false},"created_at":"2016-11-16T13:08:35Z","updated_at":"2016-11-16T13:08:35Z","body":"NowPlaying should only set the data when the track changes.\r\nAs described here https://developer.apple.com/reference/mediaplayer/mpnowplayinginfopropertyelapsedplaybacktime\r\n\r\n> Elapsed time is automatically calculated, by the system, from the previously provided elapsed time and the playback rate. Do not update this property frequently—it is not necessary.\r\n\r\nThis is how I use the plugin in a app, it might help you...\r\n\r\n```\r\n'use strict';\r\nangular.module('app').factory('AudioService', function ($q, $interval, $rootScope, TitleService) {\r\n\r\n  var audio;\r\n  var audioStatus;\r\n\r\n  var loadDefer;\r\n  var statusDefer;\r\n\r\n  var timeInterval;\r\n  var fastInterval;\r\n  var fastCurrentTime;\r\n\r\n  var service = {\r\n    loaded: false,\r\n    playing: false,\r\n    error: undefined,\r\n    currentTitle: undefined,\r\n    currentTime: 0,\r\n    playingTime: 0,\r\n\r\n    load: function (title) {\r\n\r\n      service.currentTitle = title;\r\n\r\n      loadDefer = $q.defer();\r\n      statusDefer = $q.defer();\r\n\r\n      audio = new Media(service.currentTitle.streamUrl, service.onComplete, service.onError, service.onStatus);\r\n      //audio = new Media('https://ia802508.us.archive.org/5/items/testmp3testfile/mpthreetest.mp3', service.onComplete, service.onError, service.onStatus);\r\n\r\n      console.log('load', service.currentTitle.streamUrl);\r\n\r\n      return loadDefer.promise;\r\n    },\r\n\r\n    onComplete: function () {\r\n      service.unload();\r\n    },\r\n\r\n    onError: function (error) {\r\n      service.error = error;\r\n      console.error(error);\r\n      loadDefer.reject(error);\r\n    },\r\n\r\n    unload: function () {\r\n\r\n      // Save Position\r\n      if (service.currentTitle) {\r\n        TitleService.saveSettings(service.currentTitle.id, service.currentTime);\r\n      }\r\n\r\n      if (audio) {\r\n        audio.release();\r\n      }\r\n\r\n      service.loaded = false;\r\n      service.playing = false;\r\n      service.stalled = false;\r\n      service.currentTime = 0;\r\n      service.playingTime =  0;\r\n      service.error = undefined;\r\n\r\n      console.log('unload');\r\n    },\r\n\r\n    onStatus: function (status) {\r\n\r\n      audioStatus = status;\r\n\r\n      switch (status) {\r\n        case Media.MEDIA_NONE:\r\n          console.log('status', 'MEDIA_NONE');\r\n          break;\r\n        case Media.MEDIA_READY:\r\n          console.log('status', 'MEDIA_READY');\r\n\r\n          service.loaded = true;\r\n\r\n          // Reset saved position\r\n          if (service.currentTitle.location > 0) {\r\n            audio.seekTo(service.currentTitle.location * 1000);\r\n          }\r\n\r\n          service.play();\r\n\r\n          service.setNowPlaying(service.currentTitle.location);\r\n\r\n          loadDefer.resolve(service);\r\n\r\n          $rootScope.$apply();\r\n\r\n          break;\r\n        case Media.MEDIA_STARTING:\r\n          console.log('status', 'MEDIA_STARTING');\r\n          break;\r\n        case Media.MEDIA_RUNNING:\r\n          console.log('status', 'MEDIA_RUNNING');\r\n\r\n          service.playing = true;\r\n          service.stalled = false;\r\n          service.error = undefined;\r\n\r\n          timeInterval = $interval(function () {\r\n            audio.getCurrentPosition(function (position) {\r\n              if (position > -1) {\r\n                service.currentTime = position;\r\n                service.currentTimeCountdown = service.playingTime - position;\r\n\r\n                $rootScope.$apply();\r\n              }\r\n            });\r\n          }, 1000);\r\n\r\n          $rootScope.$apply();\r\n\r\n          service.setNowPlayingPosition(service.currentTime);\r\n\r\n          console.log('play');\r\n          break;\r\n\r\n        case Media.MEDIA_PAUSED:\r\n          console.log('status', 'MEDIA_PAUSED');\r\n          service.playing = false;\r\n          service.stalled = false;\r\n\r\n          TitleService.saveSettings(service.currentTitle.id, service.currentTime);\r\n\r\n          $interval.cancel(timeInterval);\r\n\r\n          $rootScope.$apply();\r\n\r\n          service.setNowPlayingPosition(service.currentTime);\r\n\r\n          break;\r\n\r\n        case Media.MEDIA_STOPPED:\r\n          console.log('status', 'MEDIA_STOPPED');\r\n          service.playing = false;\r\n          service.loaded = false;\r\n          service.stalled = false;\r\n\r\n          TitleService.saveSettings(service.currentTitle.id, service.currentTime);\r\n\r\n          $rootScope.$apply();\r\n\r\n          service.setNowPlayingPosition(service.currentTime);\r\n\r\n          break;\r\n\r\n        case Media.MEDIA_STALLED:\r\n          console.log('status', 'MEDIA_STALLED');\r\n          service.stalled = false;\r\n          break;\r\n      }\r\n      statusDefer.notify({status: audioStatus});\r\n    },\r\n\r\n    setNowPlaying: function (currentPosition) {\r\n      if (NowPlaying) {\r\n        var title = service.currentTitle;\r\n\r\n        var params = {\r\n          title: title.name,\r\n          artist: title.author,\r\n          artwork: title.bg,\r\n          playbackDuration: title.playingTime\r\n        };\r\n\r\n        if (currentPosition) {\r\n          params.elapsedPlaybackTime = currentPosition;\r\n        }\r\n\r\n        NowPlaying.set(params);\r\n      }\r\n    },\r\n\r\n    setNowPlayingPosition: function (currentPosition) {\r\n      if (NowPlaying) {\r\n        if (currentPosition) {\r\n          NowPlaying.set({\r\n            elapsedPlaybackTime: currentPosition\r\n          });\r\n        } else {\r\n          audio.getCurrentPosition(function (position) {\r\n            NowPlaying.set({\r\n              elapsedPlaybackTime: position\r\n            });\r\n          });\r\n        }\r\n      }\r\n    },\r\n\r\n    setPlayingTime: function (time) {\r\n      service.playingTime = time || 0;\r\n    },\r\n\r\n    setCurrentTime: function (time) {\r\n      service.currentTime = time || 0;\r\n      service.currentTimeCountdown = service.playingTime - service.currentTime;\r\n    },\r\n\r\n    play: function () {\r\n      // Needs to be set twise because of async\r\n      service.playing = true;\r\n\r\n      if (audio) {\r\n        audio.play({playAudioWhenScreenIsLocked : true});\r\n      }\r\n    },\r\n\r\n    pause: function () {\r\n      // Needs to be set twise because of async\r\n      service.playing = false;\r\n\r\n      if (audio) {\r\n        audio.pause();\r\n      }\r\n    },\r\n\r\n    togglePlayPause: function () {\r\n      if (service.playing) {\r\n        service.pause();\r\n      } else {\r\n        service.play();\r\n      }\r\n    },\r\n\r\n    seek: function (value) {\r\n      if (value) {\r\n        audio.seekTo(value * 1000);\r\n      }\r\n      return value;\r\n    },\r\n\r\n    backward: function (seconds) {\r\n      audio.getCurrentPosition(function (currentTime) {\r\n        var t = currentTime - (seconds || 30);\r\n        if (t < 0) {\r\n          t = 0;\r\n        }\r\n        audio.seekTo(t * 1000);\r\n        service.currentTitle.location = t;\r\n        service.setNowPlayingPosition(t);\r\n        console.log('backward', t);\r\n      });\r\n    },\r\n\r\n    fastBackward: function () {\r\n\r\n      audio.pause();\r\n\r\n      if (fastInterval) {\r\n        $interval.cancel(fastInterval);\r\n      }\r\n\r\n      audio.getCurrentPosition(function (currentTime) {\r\n        fastCurrentTime = currentTime;\r\n        fastInterval = $interval(function fastBackwardInterval() {\r\n          var t = fastCurrentTime - 300;\r\n          if (t < 0) {\r\n            t = 0;\r\n          }\r\n          fastCurrentTime = t;\r\n\r\n          // Set display time\r\n          service.setCurrentTime(t);\r\n\r\n          // Set title time\r\n          service.currentTitle.location = t;\r\n\r\n          console.log('fast backward', fastCurrentTime);\r\n        }, 1000);\r\n      });\r\n    },\r\n\r\n    forward: function (seconds) {\r\n      audio.getCurrentPosition(function (currentTime) {\r\n        var t = currentTime + (seconds || 30);\r\n        if (t > service.playingTime) {\r\n          t = service.playingTime - 30;\r\n        }\r\n        audio.seekTo(t * 1000);\r\n        service.currentTitle.location = t;\r\n        service.setNowPlayingPosition(t);\r\n        console.log('forward', t);\r\n      });\r\n    },\r\n\r\n    fastForward: function () {\r\n\r\n      audio.pause();\r\n\r\n      if (fastInterval) {\r\n        $interval.cancel(fastInterval);\r\n      }\r\n\r\n      audio.getCurrentPosition(function (currentTime) {\r\n        fastCurrentTime = currentTime;\r\n        fastInterval = $interval(function fastForwardInterval() {\r\n          var t = fastCurrentTime + 300;\r\n          if (t > service.playingTime) {\r\n            t = service.playingTime - 30;\r\n          }\r\n          fastCurrentTime = t;\r\n\r\n          // Set display time\r\n          service.setCurrentTime(t);\r\n\r\n          // Set title time\r\n          service.currentTitle.location = t;\r\n\r\n          console.log('fast forward', fastCurrentTime);\r\n        }, 1000);\r\n      });\r\n    },\r\n\r\n    clearFast: function () {\r\n      if (fastInterval) {\r\n        $interval.cancel(fastInterval);\r\n\r\n        service.setCurrentTime(fastCurrentTime);\r\n\r\n        audio.seekTo(fastCurrentTime * 1000);\r\n\r\n        service.play();\r\n\r\n        service.setNowPlayingPosition(fastCurrentTime);\r\n\r\n        fastCurrentTime = undefined;\r\n        fastInterval = undefined;\r\n\r\n        console.log('fast forward/backward clear', fastCurrentTime);\r\n      }\r\n    }\r\n\r\n  };\r\n\r\n  // Called when commands come in from the command center\r\n  RemoteCommand.on('command', function (command) {\r\n    console.log('remote event', command, arguments);\r\n    switch (command) {\r\n      case 'pause':\r\n        service.pause();\r\n        break;\r\n      case 'play':\r\n        service.play();\r\n        break;\r\n      case 'togglePlayPause':\r\n        service.togglePlayPause();\r\n        break;\r\n      case 'nextTrack':\r\n      case 'seekForward':\r\n        service.forward();\r\n        break;\r\n      case 'previousTrack':\r\n      case 'seekBackward':\r\n        service.backward();\r\n        break;\r\n    }\r\n  });\r\n\r\n  window.addEventListener('deviceready', function setAvailableRemoteCommands() {\r\n\r\n    // Enable command center buttons\r\n    RemoteCommand.enabled('nextTrack', false);\r\n    RemoteCommand.enabled('previousTrack', false);\r\n    RemoteCommand.enabled('seekForward', true);\r\n    RemoteCommand.enabled('seekBackward', true);\r\n  }, false);\r\n\r\n  return service;\r\n});\r\n```"}}
{"actor":{"display_login":"leon"}}