{"action":"created","issue":{"url":"https://api.github.com/repos/scottschiller/SoundManager2/issues/88","labels_url":"https://api.github.com/repos/scottschiller/SoundManager2/issues/88/labels{/name}","comments_url":"https://api.github.com/repos/scottschiller/SoundManager2/issues/88/comments","events_url":"https://api.github.com/repos/scottschiller/SoundManager2/issues/88/events","html_url":"https://github.com/scottschiller/SoundManager2/issues/88","id":96518850,"number":88,"title":"Beginning playback from position irregularities","user":{"login":"jakalofnaar","id":2599611,"avatar_url":"https://avatars.githubusercontent.com/u/2599611?v=3","gravatar_id":"","url":"https://api.github.com/users/jakalofnaar","html_url":"https://github.com/jakalofnaar","followers_url":"https://api.github.com/users/jakalofnaar/followers","following_url":"https://api.github.com/users/jakalofnaar/following{/other_user}","gists_url":"https://api.github.com/users/jakalofnaar/gists{/gist_id}","starred_url":"https://api.github.com/users/jakalofnaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakalofnaar/subscriptions","organizations_url":"https://api.github.com/users/jakalofnaar/orgs","repos_url":"https://api.github.com/users/jakalofnaar/repos","events_url":"https://api.github.com/users/jakalofnaar/events{/privacy}","received_events_url":"https://api.github.com/users/jakalofnaar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-22T09:22:04Z","updated_at":"2015-07-26T01:04:11Z","closed_at":null,"body":"I'm in the process of building a player for the company I work for and one of the features I need to implement is a quality switching mechanism. When a user switches quality profiles it needs to:\r\n\r\na) Automatically begin playback of the new profile if the old profile was busy playing\r\nb) Resume playback from last position of the previous profile\r\n\r\nAccording to the documentation, using the `from` option when calling `soundManager.createSound` should begin playback from the position specified, however I'm not seeing this in all cases.\r\n\r\nBoth `webm` and `m4a` behave as intended from what testing I've done, however both `mp3` and `oga` don't, instead they:\r\n\r\n* Begin playback from the beginning of the file, but\r\n* their timer starts from the position I've asked it to start from\r\n\r\nFor example:\r\n\r\n```js\r\nsoundManager.createSound({\r\n    autoPlay: true,\r\n    url: \"http://example.com/path/to/media.mp3\",\r\n    from: 5000, // begin playback from the 5s position\r\n    whileplaying: function() {\r\n        $('#some-element-id').html(this.position);\r\n    }\r\n});\r\n```\r\n\r\nThis will begin playback of the `http://example.com/path/to/media.mp` file from the **start** of the file, but the `#some-element-id` will start with it's initial value set to `5000`."},"comment":{"url":"https://api.github.com/repos/scottschiller/SoundManager2/issues/comments/124924322","html_url":"https://github.com/scottschiller/SoundManager2/issues/88#issuecomment-124924322","issue_url":"https://api.github.com/repos/scottschiller/SoundManager2/issues/88","id":124924322,"user":{"login":"scottschiller","id":174437,"avatar_url":"https://avatars.githubusercontent.com/u/174437?v=3","gravatar_id":"","url":"https://api.github.com/users/scottschiller","html_url":"https://github.com/scottschiller","followers_url":"https://api.github.com/users/scottschiller/followers","following_url":"https://api.github.com/users/scottschiller/following{/other_user}","gists_url":"https://api.github.com/users/scottschiller/gists{/gist_id}","starred_url":"https://api.github.com/users/scottschiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottschiller/subscriptions","organizations_url":"https://api.github.com/users/scottschiller/orgs","repos_url":"https://api.github.com/users/scottschiller/repos","events_url":"https://api.github.com/users/scottschiller/events{/privacy}","received_events_url":"https://api.github.com/users/scottschiller/received_events","type":"User","site_admin":false},"created_at":"2015-07-26T01:04:11Z","updated_at":"2015-07-26T01:04:11Z","body":"Thanks for the report, pardon the late follow-up here.\r\n\r\nIt may be the use of `from` within `createSound()` here that is the cause of the problem. Sorry this isn't more clear in documentation, but there is a special case around playing a sound with position parameters before it has loaded.\r\n\r\nSM2 _should_ do the right thing and begin playback from the right position in a file regardless of type etc., but there are differences between the way Flash and HTML5 request and allow seeking within files.\r\n\r\nHTML5 will try to negotiate byte ranges (HTTP partials) by default, and thus once the `onload()` event has fired for a sound you should be able to seek to arbitrary positions within the sound.\r\n\r\nWith Flash, you must wait for `onload()` to fire before you can seek as well.\r\n\r\nAn important distinction: Under HTML5, the onload event can fire very early - it's actually when the sound has fired the HTML5 \"canplay\" event. Because Flash 8/9 use a single HTTP request to load sound, they do not use byte ranges and thus you can only seek as far as a sound has loaded. Thus, SM2 takes the conservative route and waits for the sound's load event to fire before you can seek.\r\n\r\nSM2 tries to normalize all of this within the API, such that if you create a sound object and then call `play({ position: 5000 });` for example, it will first load and wait for `onload()` before firing `setPosition()` and beginning playback.\r\n\r\nPut another way, you could do this and have the same effect:\r\n```someSound.load({\r\n  onload: function() {\r\n    this.play({\r\n      position: 5000\r\n    });\r\n  });\r\n});```"}}