Skip to content

Repeat single file #4242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 6, 2023
Merged

Repeat single file #4242

merged 2 commits into from
Apr 6, 2023

Conversation

MikeWang000000
Copy link
Contributor

@MikeWang000000 MikeWang000000 commented Mar 1, 2023


Description:
New feature: Repeat single file
Cherry-picks CarterLi@490b335
Authored by @CarterLi

CarterLi and others added 2 commits March 2, 2023 02:22
@MikeWang000000
Copy link
Contributor Author

I think this feature is very useful, so I cherry-picked it here.
However I am not macOS App developer, please help me check the changes of iina/Base.lproj/PlaylistViewController.xib, many thanks.

@low-batt
Copy link
Contributor

low-batt commented Mar 1, 2023

From a very quick look I spotted one issue that will need to be addressed. I noticed this because I've had to fix this in some of my PRs.

From CONTRIBUTING - Localizations:

We use Crowdin for localization. When there is a UI text change, only add/update the strings in Base.lproj and en.lproj. Please do not include any localization changes for other languages in the pull request. New strings on the develop branch from the en.lproj folder will be synced automatically to Crowdin, and we will fetch the latest translations from Crowdin before releasing the next version.

Changes to localization files in directories other than Base.lproj and en.lproj can cause merge conflicts when merging translations from Crowdin.

That means the changes to the file zh-Hans.lproj/Localizable.strings in this PR must instead be made in Crowdin once this PR has been merged into the develop branch and Crowdin has been updated with the changes.

@MikeWang000000
Copy link
Contributor Author

Thanks. I have noticed that and reverted the change of zh-Hans.lproj/Localizable.strings in my second commit, so there should me no change in this file after squashing this PR into single commit 🤔

@low-batt
Copy link
Contributor

low-batt commented Mar 2, 2023

My bad! Missed that the commit was undoing the changes. I forgot to use GitHub's Show all changes view. In that view it is clear the file will not be changed.

@CarterLi
Copy link
Contributor

CarterLi commented Mar 2, 2023

Ref: #3704

The author @lhc70000 promised that he would add it sometime, lets make it happen

@MikeWang000000

This comment was marked as off-topic.

@CarterLi
Copy link
Contributor

CarterLi commented Mar 2, 2023

It's not duplicate. The loop file part was removed in my old PR.

@MikeWang000000 MikeWang000000 reopened this Mar 2, 2023
@MikeWang000000
Copy link
Contributor Author

I see. Reopened ; )

Copy link
Contributor

@low-batt low-batt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In testing I found the file loop button was not displayed in the enabled (blue) state in the playlist when IINA was started with file loop enabled. I traced this to the method PlaylistViewController.viewDidAppear which is only initializing one of the buttons. See the proposed code fix to that class.

The code level design of the changes deviates from the existing method for handling IINA preferences that are tied to mpv options. This is normally done in MPVController.mpvInit by calling setUserOption. That method configures mpv initially and establishes a listener for the IINA preference changing that will sync mpv if the IINA preference is changed. We'd want to add something like this at line 218 in MPVController right after the call to setUserOption for playlistAutoPlayNext, BUT DO NOT MAKE THIS CHANGE NOW:

let trueIsInfiniteHandler: OptionObserverInfo.Transformer = { key in
      return Preference.bool(for: key) ? "inf" : nil
}
setUserOption(PK.enablePlaylistLoop, type: .other, forName: MPVOption.PlaybackControl.loopPlaylist,
              transformer: trueIsInfiniteHandler)
setUserOption(PK.enableFileLoop, type: .other, forName: MPVOption.PlaybackControl.loopFile,
              transformer: trueIsInfiniteHandler)

Using this system will allow some of the other code the PR is adding to be simplified. BUT WE DO NOT WANT TO ADDRESS THIS NOW.

I checked with @uiryuu and we want to get this change into the current release. So for now we only need to fix PlaylistViewController.viewDidAppear. We can refactor and simplify the code after this next release is cut.

@@ -149,7 +151,7 @@ class PlaylistViewController: NSViewController, NSTableViewDataSource, NSTableVi
reloadData(playlist: true, chapters: true)

let loopStatus = player.mpv.getString(MPVOption.PlaybackControl.loopPlaylist)
loopBtn.state = (loopStatus == "inf" || loopStatus == "force") ? .on : .off
loopPlaylistBtn.state = (loopStatus == "inf" || loopStatus == "force") ? .on : .off
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
let loopFileStatus = player.mpv.getString(MPVOption.PlaybackControl.loopFile)
loopFileBtn.state = loopFileStatus == "inf" ? .on : .off
}

@low-batt low-batt requested a review from uiryuu April 3, 2023 04:43
@uiryuu
Copy link
Member

uiryuu commented Apr 3, 2023

Some visual suggestions:

  • I compared the new icon you provided with the SF Pro Symbols provided by Apple, IMO the Apple's repeat.1 is visually better. We may consider using that.
    image
  • The spaces between the three icons are not identical.
    image
  • The highlight style of the new button is not the same as the pre-existing loop button. And this highlight style itself has erroneous behavior: when the window loses focus, the highlight disappears.
    image

I can help you to fix these kind of things if you are not able to or not willing to do.

A code review will be arriving shortly...

@uiryuu uiryuu self-assigned this Apr 4, 2023
@uiryuu uiryuu changed the base branch from develop to repeat-file April 6, 2023 01:01
@uiryuu uiryuu merged commit d941523 into iina:repeat-file Apr 6, 2023
@uiryuu uiryuu mentioned this pull request Apr 13, 2023
2 tasks
uiryuu pushed a commit that referenced this pull request May 3, 2023
* PlaylistView: Store preference for playlist loop status and add a `loop file` button

* Update lproj
according to `CONTRIBUTING.md`

---------

Co-authored-by: 李通洲 <carter.li@eoitek.com>
uiryuu added a commit that referenced this pull request Jan 7, 2024
* Repeat single file (#4242)

* PlaylistView: Store preference for playlist loop status and add a `loop file` button

* Update lproj
according to `CONTRIBUTING.md`

---------

Co-authored-by: 李通洲 <carter.li@eoitek.com>

* Use image from SF; merge two buttons into 1

* Use LoopMode; implement remote methods

* Fixed a bug where the icon is not correctly shown

Change the cycle to: no loop -> file loop -> playlist loop

* Fix issues about OSD message

* Fix some autolayout issues

This commit:
- Changed the resizing mode of (Scroll View - Clip View - Table View) of both
  Playlist and Chapters tabs in PlaylistViewController from Autoresizing
  Mask to Inferred
- Added constrains to the table view in both Playlist and Chapters tabs,
  which makes all of the resizing mode of the aforementioned views from
  Inferred (Autoresizing Mask) to Inferred (Constrains)
- Added "Horizontally in the container = 0" and "Vertically in the
  container = 0" for both of the table views, otherwise Xcode sometimes
  complains about missing X or Y contrains for the table view.

This commit fixes the xib editor always has the "Misplaced Views"
warning and it's actually not fixable. When you try to fix it, the view
will shrink a bit and the warning still exist. Even you just ignore it,
every time the constrains on the canvas is re-calucated, the view will
shrink as well.

* Use the proposed fix to reflect the loop status

... when the property is a number

---------

Co-authored-by: Mike Wang <mikewang000000@gmail.com>
Co-authored-by: 李通洲 <carter.li@eoitek.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants