jplayer / jPlayer

jPlayer : HTML5 Audio & Video for jQuery
http://jplayer.org/
Other
4.6k stars 1.47k forks source link

Wowza, RTMP, MP3 Audio Seeking Issues #268

Open wasimkham opened 9 years ago

wasimkham commented 9 years ago

Hi, There appears to be a seeking issue when using Wowza streaming RTMP for MP3's. I've been using jPlayer with Flash Media Server to stream MP3's with no issues but now I'm changing to Wowza. After the switch, I noticed most tracks do not seek - when you attempt to seek, the track resets to the beginning. Didn't have this issue with FMS.

I've been messing around with the Actionscript, specifically the JplayerRtmp.as file. I commented out myStream.pause(); and myStream.resume(); in the play() method and the seeking works fine now but the play/pause buttons don't work anymore.

Any ideas?

public function play(time:Number = NaN):Boolean {
            //trace("PLAY: "+time+" - isPlaying: "+myStatus.isPlaying +" - myStatus.isStartingDownload:"+myStatus.isStartingDownload);
            var wasPlaying:Boolean = myStatus.isPlaying;

            if(!isNaN(time) && myStatus.srcSet) {
                if(myStatus.isPlaying) {
                    //myStream.pause();
                    myStatus.isPlaying = false;
                }
                myStatus.pausePosition = time;
            }

            if(myStatus.isStartingDownload) {
                myStatus.playOnLoad = true; // Raise flag, captured in onMetaDataHandler()
                return true;
            } else if(myStatus.loadRequired()) {
                myStatus.playOnLoad = true; // Raise flag, captured in onMetaDataHandler()
                return load();
            } else if((myStatus.isLoading || myStatus.isLoaded) && !myStatus.isPlaying) {
                if(myStatus.metaDataReady && myStatus.pausePosition > myStatus.duration && connectString.streamTYPE != "LIVE") { // The time is invalid, ie., past the end.
                    myStream.pause(); // Since it is playing by default at this point.
                    myStatus.pausePosition = 0;
                    trace("SEEKER!");
                    myStream.seek(0);
                    timeUpdates(false);
                    timeUpdateEvent();
                    if(wasPlaying) { // For when playing and then get a play(huge)
                        this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PAUSE, myStatus));
                    }
                } else if(getSeekTimeRatio() > getLoadRatio()) { // Use an estimate based on the downloaded amount
                    myStatus.playOnSeek = true;
                    seeking(true);
                    trace("SEEKER PAUSE!");
                    myStream.pause(); // Since it is playing by default at this point.
                } else {
                    if(!isNaN(time)) { // Avoid using seek() when it is already correct.
                        trace("SEEKER3");
                        myStream.seek(myStatus.pausePosition/1000); // Since time is in ms and seek() takes seconds
                    }
                    myStatus.isPlaying = true; // Set immediately before playing. Could affects events.
                    trace("SHOULD GET RESUME!");
                    //myStream.resume();
                    timeUpdates(true);
                    if(!wasPlaying) {
                        this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PLAY, myStatus));
                    }
                }
                return true;
            } else {
                return false;
            }
        }
wasimkham commented 9 years ago

@thepag - Sorry i'm new to this, when you labelled it Bug - does that mean you've identified it as a bug or you'll look into it as a bug? Appreciate the help.

thepag commented 9 years ago

I labelled it a bug since it is clear from the ~10 other issues relating to this exact matter that it is a bug. I flagged them bug, flash and more importantly RTMP to highlight the issue. I admit that I have neglected the rtmp player a little, as I've favoured the HTML5 fallback over the flash only rtmp player.

I hope to look into this, yes, but as always I appreciate others contributing the solution.

I will try and look into it over the winter solstice, but I do need a break now and then. I'm currently maxed out on another project.