mpv.net icon indicating copy to clipboard operation
mpv.net copied to clipboard

Can No Longer Play DVD Isos

Open DReaper opened this issue 1 year ago • 2 comments

Describe the bug When playing a DVD .iso, it attempts to read it as a Blu-Ray, then fails to read. DVD playback has worked in older versions. I updated from 6.0.3.0, which worked. I am unsure if this broke in recent versions.

To Reproduce Click and drag any DVD .iso over to the player

Expected behavior In previous versions, a pop-up would ask whether it was a DVD or Blu-Ray. Selecting DVD would playback with no issues. This feature was implemented in 5.4.8.4 Beta

Additional context No issues with Blu-Ray playback, only DVDs.

DReaper avatar Apr 05 '24 02:04 DReaper

To note, this issue is happening on the latest 7.1.1.0 version.

If I mount the iso file outside of mpv.net and open it through Open DVD/Blu-Ray Drive/Folder, it will playback fine. The issue is only if you attempt to direct play a DVD iso.

DReaper avatar Apr 05 '24 14:04 DReaper

Looks like DVD iso handling was removed in newest version for some reason:

https://github.com/mpvnet-player/mpv.net/blob/3f52c1255e68389c57b2ebdeb5f9bce09cdbf827/src/MpvNet/Player.cs#L491-L497

older mpv.net handled this differently:

https://github.com/mpvnet-player/mpv.net/blob/dbf1a32580db9b718ad262279da76d019d258989/src/Misc/Player.cs#L1246-L1271

And unfortunately you can't use a lua script to handle this:

local function check_iso()
    local path = mp.get_property("path")
    local extension = string.match(path, "%.([^%.]+)$")
    local extension = extension and extension:lower()

    if extension == "iso" then
        mp.register_event("end-file", function(event)
            if event.reason == "error" then
                if mp.get_property("bluray-device") == path then
                    mp.set_property("bluray-device", "")
                    mp.set_property("dvd-device", path)
                    mp.commandv("loadfile", "dvd://")
                end
            elseif mp.get_property("dvd-device") == path then
                mp.set_property("dvd-device", "")
            end
            mp.unregister_event("end-file")
        end)

        mp.set_property("bluray-device", path)
        mp.commandv("loadfile", "bd://")
        iso_loaded=true
    end
end

mp.register_event("file-loaded", check_iso)

mp.register_event("end-file", function(event)
    if mp.get_property_bool("idle-active") then
        if iso_loaded and (event.reason == "eof" or event.reason == "stop") then
             mp.set_property("bluray-device", "")
             mp.set_property("dvd-device", "")
             iso_loaded=false
        end
    end
end)

because mpv.net hijacks the iso loading instantly and the script never executes.

Sneakpeakcss avatar Apr 05 '24 16:04 Sneakpeakcss

I was able to use MediaInfo to detect if the ISO file is DVD or Blu-ray, so this will be fixed in the next release.

public void LoadISO(string path)
{
    using var mi = new MediaInfo(path);
    
    if (mi.GetGeneral("Format") == "ISO 9660 / DVD Video")
    {
        Command("stop");
        Thread.Sleep(500);
        SetPropertyString("dvd-device", path);
        LoadFiles(new[] { @"dvd://" }, false, false);
    }
    else
    {
        Command("stop");
        Thread.Sleep(500);
        SetPropertyString("bluray-device", path);
        LoadFiles(new[] { @"bd://" }, false, false);
    }
}

stax76 avatar Jul 17 '24 00:07 stax76