Try to call state PREPARED
Only if SurfaceView is already created and MediaPlayer is prepared
Video is loaded and is ok to play.
424098
protected void tryToPrepare() {
        Log.d(TAG, "tryToPrepare");
        if (this.surfaceIsReady && this.videoIsReady) {
            if (this.mediaPlayer != null &&
                    this.mediaPlayer.getVideoWidth() != 0 &&
                    this.mediaPlayer.getVideoHeight() != 0) {
                this.initialMovieWidth = this.mediaPlayer.getVideoWidth();
                this.initialMovieHeight = this.mediaPlayer.getVideoHeight();
            }

            resize();
            stopLoading();
            currentState = State.PREPARED;

            if (shouldAutoplay)
                start();

            if (this.preparedListener != null)
                this.preparedListener.onPrepared(mediaPlayer);
        }
    }
896790
def _play(self):
        
        while True:
            if self._buffered:
                self._source.push(self._buffer.get())
512024
public void play() {
        checkState();
        if (mState == STATE_PAUSED) {
            PlaybackService.resume(getContext(), mClientKey);
        } else if (mState == STATE_STOPPED) {
            SoundCloudTrack track = mPlayerPlaylist.getCurrentTrack();
            if (track != null) {
                PlaybackService.play(getContext(), mClientKey, track);
            } else {
                return;
            }
        }
        mState = STATE_PLAYING;
    }
465842
@Override
    public void onSeekComplete(MediaPlayer mp) {
        Log.d(TAG, "onSeekComplete");

        stopLoading();
        if (lastState != null) {
            switch (lastState) {
                case STARTED: {
                    start();
                    break;
                }
                case PLAYBACKCOMPLETED: {
                    currentState = State.PLAYBACKCOMPLETED;
                    break;
                }
                case PREPARED: {
                    currentState = State.PREPARED;
                    break;
                }
            }
        }

        if (this.seekCompleteListener != null)
            this.seekCompleteListener.onSeekComplete(mp);
    }
103466
public void pause() throws IllegalStateException {
        Log.d(TAG, "pause");
        if (mediaPlayer != null) {
            currentState = State.PAUSED;
            mediaPlayer.pause();
        } else throw new RuntimeException("Media Player is not initialized");
    }
275571
private final void playLive() throws IOException {
        // change state
        subscriberStream.setState(StreamState.PLAYING);
        IMessageInput in = msgInReference.get();
        IMessageOutput out = msgOutReference.get();
        if (in != null && out != null) {
            // get the stream so that we can grab any metadata and decoder configs
            IBroadcastStream stream = (IBroadcastStream) ((IBroadcastScope) in).getClientBroadcastStream();
            // prevent an NPE when a play list is created and then immediately flushed
            int ts = 0;
            if (stream != null) {
                Notify metaData = stream.getMetaData();
                //check for metadata to send
                if (metaData != null) {
                    ts = metaData.getTimestamp();
                    log.debug("Metadata is available");
                    RTMPMessage metaMsg = RTMPMessage.build(metaData, metaData.getTimestamp());
                    sendMessage(metaMsg);
                } else {
                    log.debug("No metadata available");
                }
                IStreamCodecInfo codecInfo = stream.getCodecInfo();
                log.debug("Codec info: {}", codecInfo);
                if (codecInfo instanceof StreamCodecInfo) {
                    StreamCodecInfo info = (StreamCodecInfo) codecInfo;
                    // handle video codec with configuration
                    IVideoStreamCodec videoCodec = info.getVideoCodec();
                    log.debug("Video codec: {}", videoCodec);
                    if (videoCodec != null) {
                        // check for decoder configuration to send
                        IoBuffer config = videoCodec.getDecoderConfiguration();
                        if (config != null) {
                            log.debug("Decoder configuration is available for {}", videoCodec.getName());
                            VideoData conf = new VideoData(config, true);
                            log.debug("Pushing video decoder configuration");
                            sendMessage(RTMPMessage.build(conf, ts));
                        }
                        // check for keyframes to send
                        FrameData[] keyFrames = videoCodec.getKeyframes();
                        for (FrameData keyframe : keyFrames) {
                            log.debug("Keyframe is available");
                            VideoData video = new VideoData(keyframe.getFrame(), true);
                            log.debug("Pushing keyframe");
                            sendMessage(RTMPMessage.build(video, ts));
                        }
                    } else {
                        log.debug("No video decoder configuration available");
                    }
                    // handle audio codec with configuration
                    IAudioStreamCodec audioCodec = info.getAudioCodec();
                    log.debug("Audio codec: {}", audioCodec);
                    if (audioCodec != null) {
                        // check for decoder configuration to send
                        IoBuffer config = audioCodec.getDecoderConfiguration();
                        if (config != null) {
                            log.debug("Decoder configuration is available for {}", audioCodec.getName());
                            AudioData conf = new AudioData(config.asReadOnlyBuffer());
                            log.debug("Pushing audio decoder configuration");
                            sendMessage(RTMPMessage.build(conf, ts));
                        }
                    } else {
                        log.debug("No audio decoder configuration available");
                    }
                }
            }
        } else {
            throw new IOException(String.format("A message pipe is null - in: %b out: %b", (msgInReference == null), (msgOutReference == null)));
        }
        configsDone = true;
    }
1244559
@Override
    protected void onCreate(Bundle savedInstanceState)
    {
        setTheme(SampleList.THEME); //Used for theme switching in samples
        // Be sure to call the super class.
        super.onCreate(savedInstanceState);

        // See assets/res/any/layout/hello_world.xml for this
        // view layout definition, which is being set here as
        // the content of our screen.
        setContentView(R.layout.send_result);

        // Watch for button clicks.
        Button button = (Button)findViewById(R.id.corky);
        button.setOnClickListener(mCorkyListener);
        button = (Button)findViewById(R.id.violet);
        button.setOnClickListener(mVioletListener);
    }
671634
protected void prepare() throws IllegalStateException {
        Log.d(TAG, "prepare");
        startLoading();

        this.currentState = State.PREPARING;
        this.mediaPlayer.prepareAsync();
    }
1247185
function setHeadsetState(newState){

    if (newState){

        appPlaying = true;
        appActive = true;

    }else{

        if (removeHeadsetPausesPlay)
            appPlaying = false;

    }


}
533415
function() {
  this.lastTime = 0;

  // Setup our different game components.
  this.audio = new Sound();
  this.player = new Player(10, 26, Math.PI * 1.9, 2.5);
  this.controls = new Controls();
  this.map = new Map(25);
  this.camera = new Camera(isMobile ? 256 : 512);
  
  requestAnimationFrame(this.tick.bind(this));
}
1361543
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_youtube_sample);
    ButterKnife.inject(this);
    initializeYoutubeFragment();
    initializeDraggablePanel();
    hookDraggablePanelListeners();
  }
953658
def pauseMovie(self):
    """"""
    if self.state == self.PLAYING:
      self.sendRtspRequest(self.PAUSE)
158672
@Override
    protected boolean prepare(final Context2D context, final Attributes attr, final double alpha)
    {
        if (m_inits)
        {
            init();

            if ((null == m_error) && (isAutoPlay()))
            {
                play();
            }
        }
        int wide = getWidth();

        int high = getHeight();

        if (null != m_error)
        {
            if (false == context.isSelection())
            {
                if (wide < 1)
                {
                    wide = MOVIE_ERROR_WIDE;
                }
                if (high < 1)
                {
                    high = MOVIE_ERROR_HIGH;
                }
                context.save();

                context.setFillColor(ColorName.BLACK);

                context.rect(0, 0, wide, high);

                context.fill();

                context.setTextAlign(TextAlign.CENTER);

                context.setTextBaseline(TextBaseLine.MIDDLE);

                context.setTextFont(getTextBestFit(context, m_error, wide));

                context.setFillColor(ColorName.WHITE);

                context.rect(0, 0, wide, high);

                context.clip();

                context.fillText(m_error, wide / 2.0d, high / 2.0d);

                context.restore();
            }
        }
        else
        {
            if ((wide < 1) || (high < 1))
            {
                return false;
            }
            if (context.isSelection())
            {
                final String color = getColorKey();

                if (null != color)
                {
                    context.save();

                    context.setFillColor(color);

                    context.fillRect(0, 0, wide, high);

                    context.restore();
                }
                return false;
            }
            if (isEnded())
            {
                if (null != m_postr)
                {
                    context.save();

                    context.setGlobalAlpha(alpha);

                    context.drawImage(m_postr, 0, 0, wide, high);

                    context.restore();
                }
                else
                {
                    final String fill = getFillColor();

                    if (null != fill)
                    {
                        context.save();

                        context.setGlobalAlpha(alpha);

                        context.setFillColor(fill);

                        context.fillRect(0, 0, wide, high);

                        context.restore();
                    }
                }
                return false;
            }
            context.save();

            context.setGlobalAlpha(alpha);

            if ((false == m_xorig) && (m_filters.isActive()))
            {
                try
                {
                    m_canvas.getContext().drawImage(m_video.getElement(), 0, 0, wide, high);

                    m_canvas.getContext().putImageData(m_filters.filter(m_canvas.getContext().getImageData(0, 0, wide, high), false), 0, 0);

                    context.drawImage(m_canvas.getElement(), 0, 0, wide, high);
                }
                catch (final Exception e)
                {
                    // We should only get an exception here if the URL is cross-origin, and getImageData() is basically a security exception.
                    // ...or other unknown bad things, either way, turn off filtering. DSJ 7/18/2014

                    context.drawImage(m_video.getElement(), 0, 0, wide, high);

                    m_xorig = true;

                    LienzoCore.get().error("ERROR: In Movie filtering " + m_video.getSrc() + " " + e.getMessage());
                }
            }
            else
            {
                context.drawImage(m_video.getElement(), 0, 0, wide, high);
            }
            context.restore();
        }
        return false;
    }
680603
def pause(self):
		
		if self.decoder.status == mediadecoder.PAUSED:
			self.decoder.pause()
			self.paused = False
		elif self.decoder.status == mediadecoder.PLAYING:
			self.decoder.pause()
			self.paused = True
		else:
			print("Player not in pausable state")
552702
private void initPlaybackStateBuilder() {
        mStateBuilder = new PlaybackStateCompat.Builder();
        mStateBuilder.setActions(
                PlaybackStateCompat.ACTION_PLAY
                        | PlaybackStateCompat.ACTION_PAUSE
                        | PlaybackStateCompat.ACTION_PLAY_PAUSE
                        | PlaybackStateCompat.ACTION_SKIP_TO_NEXT
                        | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS
        );
    }
692465
public void onHostActivityPaused() {
        Log.i(TAG, "onHostActivityPaused");
        synchronized (mReadyForFrameFence) {
            // Pause the GLSurfaceView's Renderer thread
            if (mDisplayView != null)
                mDisplayView.onPause();
            // Release camera if we're not recording
            if (!mRecording && mSurfaceTexture != null) {
                if (VERBOSE) Log.i("CameraRelease", "Releasing camera");
                if (mDisplayView != null)
                    releaseDisplayView();
                mHandler.sendMessage(mHandler.obtainMessage(MSG_RELEASE_CAMERA));
            }
        }
    }
1002852
@Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        ensureList();
    }