| 48 | } |
| 49 | |
| 50 | bool Player::load(const MediaFile &f) { |
| 51 | |
| 52 | file = f; |
| 53 | std::string path = file.path; |
| 54 | #ifdef __SMB2__ |
| 55 | #if 0 |
| 56 | if (Utility::startWith(path, "smb://")) { |
| 57 | std::replace(path.begin(), path.end(), '\\', '/'); |
| 58 | } |
| 59 | #endif |
| 60 | #endif |
| 61 | |
| 62 | // disable subtitles if slang option not set in "mpv.conf" (overridden by "watch_later") |
| 63 | char *slang = mpv_get_property_string(mpv->getHandle(), "slang"); |
| 64 | if (strlen(slang) <= 0) { |
| 65 | printf("slang not set, disabling subtitles by default"); |
| 66 | mpv_set_option_string(mpv->getHandle(), "sid", "no"); |
| 67 | } |
| 68 | |
| 69 | int res = mpv->load(path, Mpv::LoadType::Replace, "pause=yes,speed=1"); |
| 70 | if (res != 0) { |
| 71 | main->getStatus()->show("Error...", "Could not play file:\n" + std::string(mpv_error_string(res))); |
| 72 | printf("Player::load: could not play file: %s\n", mpv_error_string(res)); |
| 73 | return false; |
| 74 | } |
| 75 | |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | void Player::onLoadEvent() { |
| 80 | // load/update media information |