Skip to content
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

[Bug] togglePlayPause, next, and previous do not seem to respecting sessionId parameter #189

Open
mushfikurr opened this issue Jan 19, 2025 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed type: bug Something isn't working

Comments

@mushfikurr
Copy link

mushfikurr commented Jan 19, 2025

Describe the bug

When passing in a sessionId, the respective session's play/pause state is not affected:

media.togglePlayPause({ sessionId: "some_session_id" })
media.next({ sessionId: "some_session_id" })
media-repro.mp4

Reproduction

import { useEffect, useState } from "react";
import * as zebar from "zebar";

const providers = zebar.createProviderGroup({
  media: { type: "media" },
  network: { type: "network" },
  glazewm: { type: "glazewm" },
  cpu: { type: "cpu" },
  date: { type: "date", formatting: "EEE d MMM t", locale: "en-GB" },
  memory: { type: "memory" },
  weather: { type: "weather" },
});

function App() {
  const [output, setOutput] = useState(providers.outputMap);
  const [currSession, setCurrSession] = useState<zebar.MediaSession | null>(
    output.media?.currentSession ?? null
  );

  useEffect(() => {
    providers.onOutput(() => setOutput(providers.outputMap));
  }, []);

  return (
    <div
      style={{
        backgroundColor: "black",
        color: "white",
        height: "100%",
      }}
    >
      <div>
        {output.media?.allSessions.map((session: zebar.MediaSession) => (
          <button
            key={session.sessionId}
            style={{
              color:
                session.sessionId === currSession?.sessionId ? "red" : "black",
            }}
            onClick={() => setCurrSession(session)}
          >
            {session.sessionId} ({session.title})
          </button>
        ))}
        <button
          onClick={() => {
            output.media?.togglePlayPause({
              sessionId: currSession?.sessionId,
            });
          }}
        >
          togglePlayPause
        </button>
        <p>
          now playing: {currSession?.sessionId} | {currSession?.title}
          {"|"}
          {currSession?.isPlaying ? "playing" : "not playing"}
        </p>
      </div>
    </div>
  );
}

export default App;

Stack trace or error logs (if applicable)

Version number

"zebar": "^2.6.1"

@mushfikurr mushfikurr added the type: bug Something isn't working label Jan 19, 2025
@github-project-automation github-project-automation bot moved this to 📬 Needs triage in zebar Jan 19, 2025
@lars-berger lars-berger added help wanted Extra attention is needed good first issue Good for newcomers labels Jan 20, 2025
@lars-berger lars-berger moved this from 📬 Needs triage to 📋 Available in zebar Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed type: bug Something isn't working
Projects
Status: 📋 Available
Development

No branches or pull requests

2 participants