<commit_before>// For conditions of distribution and use, see copyright notice in license.txt

#include "StableHeaders.h"
#include "DebugOperatorNew.h"

#include <QUrl>
#include <phonon/VideoPlayer>
#include <phonon/MediaObject>
#include <phonon/VideoWidget>
#include "PhononPlayerModule.h"
#include "VideoPlayer.h"

#include "MemoryLeakCheck.h"

namespace PlayerService
{
    VideoPlayer::VideoPlayer(const QString &url) : media_object_(0), video_widget_(0)
    {
        Play(url);
    }

    VideoPlayer::~VideoPlayer()
    {
        if (media_object_)
        {
            if (media_object_->state() == Phonon::PlayingState)
                media_object_->stop();

            media_object_->clear();
        }
    }

    void VideoPlayer::Play(const QString &url)
    {
        media_object_ = new Phonon::MediaObject(this);
        video_widget_ = new Phonon::VideoWidget(this);
        Phonon::createPath(media_object_, video_widget_);
        QObject::connect(media_object_, SIGNAL(finished()), this, SLOT(Restart()));
        QObject::connect(media_object_, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(CheckState()));

        media_object_->setCurrentSource(url);
        media_object_->play();
    }
       
    void VideoPlayer::Restart()
    {
        if (media_object_ && (media_object_->state() == Phonon::StoppedState || media_object_->state() == Phonon::PausedState))
        {
            if (media_object_->isSeekable())
                media_object_->seek(0);
            media_object_->play();
        }
    }

    void VideoPlayer::CheckState()
    {
        if (media_object_->state() == Phonon::ErrorState)
        {
            QString message = QString("Videoplayback error [%1] for %2").arg(media_object_->errorString()).arg(media_object_->currentSource().url().toString());
            PhononPlayerModule::LogError(message.toStdString());
            return;
        }
        if (media_object_->state() == Phonon::StoppedState || media_object_->state() == Phonon::PausedState)
            Restart();<commit_msg>Changed video playback accept ratio automatically to scale with the size of the playback widget.<commit_after>// For conditions of distribution and use, see copyright notice in license.txt

#include "StableHeaders.h"
#include "DebugOperatorNew.h"

#include <QUrl>
#include <phonon/VideoPlayer>
#include <phonon/MediaObject>
#include <phonon/VideoWidget>
#include "PhononPlayerModule.h"
#include "VideoPlayer.h"

#include "MemoryLeakCheck.h"

namespace PlayerService
{
    VideoPlayer::VideoPlayer(const QString &url) : media_object_(0), video_widget_(0)
    {
        Play(url);
    }

    VideoPlayer::~VideoPlayer()
    {
        if (media_object_)
        {
            if (media_object_->state() == Phonon::PlayingState)
                media_object_->stop();

            media_object_->clear();
        }
    }

    void VideoPlayer::Play(const QString &url)
    {
        media_object_ = new Phonon::MediaObject(this);
        video_widget_ = new Phonon::VideoWidget(this);
        video_widget_->setAspectRatio(Phonon::VideoWidget::AspectRatioWidget);

        Phonon::createPath(media_object_, video_widget_);
        QObject::connect(media_object_, SIGNAL(finished()), this, SLOT(Restart()));
        QObject::connect(media_object_, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(CheckState()));

        media_object_->setCurrentSource(url);
        media_object_->play();
    }
       
    void VideoPlayer::Restart()
    {
        if (media_object_ && (media_object_->state() == Phonon::StoppedState || media_object_->state() == Phonon::PausedState))
        {
            if (media_object_->isSeekable())
                media_object_->seek(0);
            media_object_->play();
        }
    }

    void VideoPlayer::CheckState()
    {
        if (media_object_->state() == Phonon::ErrorState)
        {
            QString message = QString("Videoplayback error [%1] for %2").arg(media_object_->errorString()).arg(media_object_->currentSource().url().toString());
            PhononPlayerModule::LogError(message.toStdString());
            return;
        }
        if (media_object_->state() == Phonon::StoppedState || media_object_->state() == Phonon::PausedState)
            Restart();
{'fraction_non_alphanumeric': 0.13728694840065375, 'fraction_numerical': 0.0023348120476301658, 'mean_word_length': 3.1311475409836067, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2627834', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1253, 'n_words': 216}